diff --git a/Applications/CoreApp/MitkCoreApp.cpp b/Applications/CoreApp/MitkCoreApp.cpp
index 8f02537b8d..e3c6e1168c 100644
--- a/Applications/CoreApp/MitkCoreApp.cpp
+++ b/Applications/CoreApp/MitkCoreApp.cpp
@@ -1,93 +1,91 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include
#include
#include
#include
class QSafeApplication : public QApplication
{
public:
QSafeApplication(int& argc, char** argv)
: QApplication(argc, argv)
{}
/**
* Reimplement notify to catch unhandled exceptions and open an error message.
*
* @param receiver
* @param event
* @return
*/
bool notify(QObject* receiver, QEvent* event)
{
QString msg;
try
{
return QApplication::notify(receiver, event);
} catch (Poco::Exception& e)
{
msg = QString::fromStdString(e.displayText());
} catch (std::exception& e)
{
msg = e.what();
} catch (...)
{
msg = "Unknown exception";
}
QString
text(
"An error occurred. You should save all data and quit the program to prevent possible data loss.\nSee the error log for details.\n\n");
text += msg;
QMessageBox::critical(0, "Error", text);
return false;
}
};
int main(int argc, char** argv)
{
QSafeApplication safeApp(argc, argv);
safeApp.setApplicationName("MitkCoreApp");
safeApp.setOrganizationName("DKFZ");
// These paths replace the .ini file and are tailored for installation
// packages created with CPack. If a .ini file is presented, it will
// overwrite the settings in MapConfiguration
- Poco::Path basePath(argv[0]);
- basePath.setFileName("");
+ QDir basePath(argv[0]);
- Poco::Path provFile(basePath);
- provFile.setFileName("MitkCoreApp.provisioning");
+ QString provFile = basePath.absoluteFilePath("MitkCoreApp.provisioning");
Poco::Util::MapConfiguration* coreConfig(new Poco::Util::MapConfiguration());
- coreConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString());
- coreConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.coreapplication");
+ coreConfig->setString(berry::Platform::ARG_PROVISIONING.toStdString(), provFile.toStdString());
+ coreConfig->setString(berry::Platform::ARG_APPLICATION.toStdString(), "org.mitk.qt.coreapplication");
// Preload the org.mitk.gui.qt.common plug-in (and hence also Qmitk) to speed
// up a clean-cache start. This also works around bugs in older gcc and glibc implementations,
// which have difficulties with multiple dynamic opening and closing of shared libraries with
// many global static initializers. It also helps if dependent libraries have weird static
// initialization methods and/or missing de-initialization code.
- coreConfig->setString(berry::Platform::ARG_PRELOAD_LIBRARY, "liborg_mitk_gui_qt_common");
+ coreConfig->setString(berry::Platform::ARG_PRELOAD_LIBRARY.toStdString(), "liborg_mitk_gui_qt_common");
return berry::Starter::Run(argc, argv, coreConfig);
}
diff --git a/Applications/Diffusion/MitkDiffusion.cpp b/Applications/Diffusion/MitkDiffusion.cpp
index 532034a804..77b5b80643 100644
--- a/Applications/Diffusion/MitkDiffusion.cpp
+++ b/Applications/Diffusion/MitkDiffusion.cpp
@@ -1,186 +1,186 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
+#include
+#include
class QtSafeApplication : public QtSingleApplication
{
public:
QtSafeApplication(int& argc, char** argv) : QtSingleApplication(argc, argv)
{}
/**
* Reimplement notify to catch unhandled exceptions and open an error message.
*
* @param receiver
* @param event
* @return
*/
bool notify(QObject* receiver, QEvent* event)
{
QString msg;
try
{
return QApplication::notify(receiver, event);
}
catch (Poco::Exception& e)
{
msg = QString::fromStdString(e.displayText());
}
catch (std::exception& e)
{
msg = e.what();
}
catch (...)
{
msg = "Unknown exception";
}
QString text("An error occurred. You should save all data and quit the program to "
"prevent possible data loss.\nSee the error log for details.\n\n");
text += msg;
QMessageBox::critical(0, "Error", text);
return false;
}
};
int main(int argc, char** argv)
{
// Create a QApplication instance first
QtSafeApplication qSafeApp(argc, argv);
qSafeApp.setApplicationName("MitkDiffusion");
qSafeApp.setOrganizationName("DKFZ");
bool showSplashScreen(true);
QPixmap pixmap( ":/splash/splashscreen.png" );
QSplashScreen splash( pixmap );
splash.setMask( pixmap.mask() );
splash.setWindowFlags( Qt::SplashScreen | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint );
if (showSplashScreen)
{
splash.show();
qSafeApp.sendPostedEvents();
qSafeApp.processEvents();
qSafeApp.flush();
QTimer::singleShot(4000, &splash, SLOT(close()) );
}
// This function checks if an instance is already running
// and either sends a message to it (containing the command
// line arguments) or checks if a new instance was forced by
// providing the BlueBerry.newInstance command line argument.
// In the latter case, a path to a temporary directory for
// the new application's storage directory is returned.
QString storageDir = handleNewAppInstance(&qSafeApp, argc, argv, "BlueBerry.newInstance");
// These paths replace the .ini file and are tailored for installation
// packages created with CPack. If a .ini file is presented, it will
// overwrite the settings in MapConfiguration
- Poco::Path basePath(argv[0]);
- basePath.setFileName("");
+ QDir basePath(argv[0]);
- Poco::Path provFile(basePath);
- provFile.setFileName("MitkDiffusion.provisioning");
+ QString provFile = basePath.absoluteFilePath("MitkDiffusion.provisioning");
Poco::Util::MapConfiguration* diffConfig(new Poco::Util::MapConfiguration());
if (!storageDir.isEmpty())
{
- diffConfig->setString(berry::Platform::ARG_STORAGE_DIR, storageDir.toStdString());
+ diffConfig->setString(berry::Platform::ARG_STORAGE_DIR.toStdString(), storageDir.toStdString());
}
- diffConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString());
- diffConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.diffusionimagingapp");
+ diffConfig->setString(berry::Platform::ARG_PROVISIONING.toStdString(), provFile.toStdString());
+ diffConfig->setString(berry::Platform::ARG_APPLICATION.toStdString(), "org.mitk.qt.diffusionimagingapp");
QStringList preloadLibs;
// Preload the org.mitk.gui.qt.ext plug-in (and hence also QmitkExt) to speed
// up a clean-cache start. This also works around bugs in older gcc and glibc implementations,
// which have difficulties with multiple dynamic opening and closing of shared libraries with
// many global static initializers. It also helps if dependent libraries have weird static
// initialization methods and/or missing de-initialization code.
preloadLibs << "liborg_mitk_gui_qt_ext";
QMap preloadLibVersion;
#ifdef Q_OS_MAC
const QString libSuffix = ".dylib";
#elif defined(Q_OS_UNIX)
const QString libSuffix = ".so";
#elif defined(Q_OS_WIN)
const QString libSuffix = ".dll";
#else
const QString libSuffix;
#endif
for (QStringList::Iterator preloadLibIter = preloadLibs.begin(),
iterEnd = preloadLibs.end(); preloadLibIter != iterEnd; ++preloadLibIter)
{
QString& preloadLib = *preloadLibIter;
// In case the application is started from an install directory
QString tempLibraryPath = QCoreApplication::applicationDirPath() + "/plugins/" + preloadLib + libSuffix;
QFile preloadLibrary (tempLibraryPath);
#ifdef Q_OS_MAC
if (!preloadLibrary.exists())
{
// In case the application is started from a build tree
QString relPath = "/../../../plugins/" + preloadLib + libSuffix;
tempLibraryPath = QCoreApplication::applicationDirPath() + relPath;
preloadLibrary.setFileName(tempLibraryPath);
}
#endif
if(preloadLibrary.exists())
{
preloadLib = tempLibraryPath;
}
// Else fall back to the QLibrary search logic
}
QString preloadConfig;
Q_FOREACH(const QString& preloadLib, preloadLibs)
{
preloadConfig += preloadLib + preloadLibVersion[preloadLib] + ",";
}
preloadConfig.chop(1);
- diffConfig->setString(berry::Platform::ARG_PRELOAD_LIBRARY, preloadConfig.toStdString());
+ diffConfig->setString(berry::Platform::ARG_PRELOAD_LIBRARY.toStdString(), preloadConfig.toStdString());
// Seed the random number generator, once at startup.
QTime time = QTime::currentTime();
qsrand((uint)time.msec());
return berry::Starter::Run(argc, argv, diffConfig);
}
diff --git a/Applications/Workbench/MitkWorkbench.cpp b/Applications/Workbench/MitkWorkbench.cpp
index 0e2df976a4..7490daa4cb 100644
--- a/Applications/Workbench/MitkWorkbench.cpp
+++ b/Applications/Workbench/MitkWorkbench.cpp
@@ -1,211 +1,214 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
+#include
+#include
+#include
#include
#include
#include
class QtSafeApplication : public QtSingleApplication
{
public:
QtSafeApplication(int& argc, char** argv) : QtSingleApplication(argc, argv)
{}
/**
* Reimplement notify to catch unhandled exceptions and open an error message.
*
* @param receiver
* @param event
* @return
*/
bool notify(QObject* receiver, QEvent* event)
{
QString msg;
try
{
return QApplication::notify(receiver, event);
}
catch (mitk::Exception& e)
{
msg = QString("MITK Exception:\n\n")
+ QString("Description: ")
+ QString(e.GetDescription()) + QString("\n\n")
+ QString("Filename: ") + QString(e.GetFile()) + QString("\n\n")
+ QString("Line: ") + QString::number(e.GetLine());
}
catch (Poco::Exception& e)
{
msg = QString::fromStdString(e.displayText());
}
catch (std::exception& e)
{
msg = e.what();
}
catch (...)
{
msg = "Unknown exception";
}
MITK_ERROR << "An error occurred: " << msg.toStdString();
QMessageBox msgBox;
msgBox.setText("An error occurred. You should save all data and quit the program to prevent possible data loss.");
msgBox.setDetailedText(msg);
msgBox.setIcon(QMessageBox::Critical);
msgBox.addButton(trUtf8("Exit immediately"), QMessageBox::YesRole);
msgBox.addButton(trUtf8("Ignore"), QMessageBox::NoRole);
int ret = msgBox.exec();
switch(ret)
{
case 0:
MITK_ERROR << "The program was closed.";
this->closeAllWindows();
break;
case 1:
MITK_ERROR << "The error was ignored by the user. The program may be in a corrupt state and don't behave like expected!";
break;
}
return false;
}
};
int main(int argc, char** argv)
{
// Create a QApplication instance first
QtSafeApplication qSafeApp(argc, argv);
qSafeApp.setApplicationName("MITK Workbench");
qSafeApp.setOrganizationName("DKFZ");
// This function checks if an instance is already running
// and either sends a message to it (containing the command
// line arguments) or checks if a new instance was forced by
// providing the BlueBerry.newInstance command line argument.
// In the latter case, a path to a temporary directory for
// the new application's storage directory is returned.
QString storageDir = handleNewAppInstance(&qSafeApp, argc, argv, "BlueBerry.newInstance");
if (storageDir.isEmpty())
{
// This is a new instance and no other instance is already running. We specify
// the storage directory here (this is the same code as in berryInternalPlatform.cpp
// so that we can re-use the location for the persistent data location of the
// the CppMicroServices library.
// Append a hash value of the absolute path of the executable to the data location.
// This allows to start the same application from different build or install trees.
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
storageDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + '_';
#else
storageDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + '_';
#endif
storageDir += QString::number(qHash(QCoreApplication::applicationDirPath())) + QDir::separator();
}
us::ModuleSettings::SetStoragePath((storageDir + QString("us") + QDir::separator()).toStdString());
// These paths replace the .ini file and are tailored for installation
// packages created with CPack. If a .ini file is presented, it will
// overwrite the settings in MapConfiguration
QDir basePath(argv[0]);
QString provFile = basePath.absoluteFilePath("MitkWorkbench.provisioning");
Poco::Util::MapConfiguration* extConfig(new Poco::Util::MapConfiguration());
if (!storageDir.isEmpty())
{
extConfig->setString(berry::Platform::ARG_STORAGE_DIR.toStdString(), storageDir.toStdString());
}
extConfig->setString(berry::Platform::ARG_PROVISIONING.toStdString(), provFile.toStdString());
extConfig->setString(berry::Platform::ARG_APPLICATION.toStdString(), "org.mitk.qt.extapplication");
QStringList preloadLibs;
// Preload the org.mitk.gui.qt.ext plug-in (and hence also QmitkExt) to speed
// up a clean-cache start. This also works around bugs in older gcc and glibc implementations,
// which have difficulties with multiple dynamic opening and closing of shared libraries with
// many global static initializers. It also helps if dependent libraries have weird static
// initialization methods and/or missing de-initialization code.
preloadLibs << "liborg_mitk_gui_qt_ext";
QMap preloadLibVersion;
#ifdef Q_OS_MAC
const QString libSuffix = ".dylib";
#elif defined(Q_OS_UNIX)
const QString libSuffix = ".so";
#elif defined(Q_OS_WIN)
const QString libSuffix = ".dll";
#else
const QString libSuffix;
#endif
for (QStringList::Iterator preloadLibIter = preloadLibs.begin(),
iterEnd = preloadLibs.end(); preloadLibIter != iterEnd; ++preloadLibIter)
{
QString& preloadLib = *preloadLibIter;
// In case the application is started from an install directory
QString tempLibraryPath = QCoreApplication::applicationDirPath() + "/plugins/" + preloadLib + libSuffix;
QFile preloadLibrary (tempLibraryPath);
#ifdef Q_OS_MAC
if (!preloadLibrary.exists())
{
// In case the application is started from a build tree
QString relPath = "/../../../plugins/" + preloadLib + libSuffix;
tempLibraryPath = QCoreApplication::applicationDirPath() + relPath;
preloadLibrary.setFileName(tempLibraryPath);
}
#endif
if(preloadLibrary.exists())
{
preloadLib = tempLibraryPath;
}
// Else fall back to the QLibrary search logic
}
QString preloadConfig;
Q_FOREACH(const QString& preloadLib, preloadLibs)
{
preloadConfig += preloadLib + preloadLibVersion[preloadLib] + ",";
}
preloadConfig.chop(1);
extConfig->setString(berry::Platform::ARG_PRELOAD_LIBRARY.toStdString(), preloadConfig.toStdString());
// Seed the random number generator, once at startup.
QTime time = QTime::currentTime();
qsrand((uint)time.msec());
// Run the workbench.
return berry::Starter::Run(argc, argv, extConfig);
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.expressions/files.cmake b/BlueBerry/Bundles/org.blueberry.core.expressions/files.cmake
index dc7bc9f4da..a38c51dd5b 100644
--- a/BlueBerry/Bundles/org.blueberry.core.expressions/files.cmake
+++ b/BlueBerry/Bundles/org.blueberry.core.expressions/files.cmake
@@ -1,58 +1,59 @@
set(MOC_H_FILES
+ src/internal/berryExpressionPlugin.h
)
set(CACHED_RESOURCE_FILES
plugin.xml
)
set(SRC_CPP_FILES
berryElementHandler.cpp
berryEvaluationContext.cpp
berryEvaluationResult.cpp
berryExpression.cpp
berryExpressionConverter.cpp
berryExpressionInfo.cpp
berryExpressionTagNames.cpp
berryICountable.h
berryIEvaluationContext.cpp
berryIIterable.cpp
berryIPropertyTester.cpp
berryIVariableResolver.cpp
berryPropertyTester.cpp
)
set(INTERNAL_CPP_FILES
berryAdaptExpression.cpp
berryAndExpression.cpp
berryCompositeExpression.cpp
berryCountExpression.cpp
berryDefaultVariable.cpp
berryDefinitionRegistry.cpp
berryEnablementExpression.cpp
berryEqualsExpression.cpp
berryExpressionPlugin.cpp
berryExpressions.cpp
berryExpressionStatus.cpp
berryInstanceofExpression.cpp
berryIterateExpression.cpp
berryNotExpression.cpp
berryOrExpression.cpp
berryProperty.cpp
berryPropertyTesterDescriptor.cpp
berryReferenceExpression.cpp
berryResolveExpression.cpp
berryStandardElementHandler.cpp
berrySystemTestExpression.cpp
berryTestExpression.cpp
berryTypeExtension.cpp
berryTypeExtensionManager.cpp
berryWithExpression.cpp
)
foreach(file ${SRC_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/${file})
endforeach(file ${SRC_CPP_FILES})
foreach(file ${INTERNAL_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/internal/${file})
endforeach(file ${INTERNAL_CPP_FILES})
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/CMakeLists.txt b/BlueBerry/Bundles/org.blueberry.core.runtime/CMakeLists.txt
index 064c8c58eb..2944414751 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/CMakeLists.txt
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/CMakeLists.txt
@@ -1,34 +1,38 @@
project(org_blueberry_core_runtime)
set(QT_USE_QTXML 1)
MACRO_CREATE_CTK_PLUGIN(EXPORT_DIRECTIVE org_blueberry_core_runtime_EXPORT
EXPORTED_INCLUDE_SUFFIXES src src/application src/service src/registry)
+target_link_libraries(${PLUGIN_TARGET} PUBLIC Poco::Foundation Poco::Util Poco::XML)
+
+# Set compiler flags
+target_compile_definitions(${PLUGIN_TARGET} PUBLIC "$<$:POCO_NO_UNWINDOWS;WIN32_LEAN_AND_MEAN>")
+
add_executable(${OSGI_APP} MACOSX_BUNDLE "src/application/berryMain.cpp")
-target_link_libraries(${OSGI_APP} ${PROJECT_NAME} mbilog)
+target_link_libraries(${OSGI_APP} PRIVATE ${PROJECT_NAME} mbilog)
if(_ctk_test_plugins)
add_dependencies(${OSGI_APP} ${_ctk_test_plugins})
add_dependencies(BlueBerry ${OSGI_APP})
set_property(TARGET ${OSGI_APP} APPEND PROPERTY LABELS BlueBerry)
endif()
configure_file(src/application/solstice.ini
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_APP}.ini)
add_executable(${OSGI_UI_APP} MACOSX_BUNDLE "src/application/berryMainUI.cpp")
-target_link_libraries(${OSGI_UI_APP} ${PROJECT_NAME} mbilog)
+target_link_libraries(${OSGI_UI_APP} PRIVATE ${PROJECT_NAME} mbilog)
if(_ctk_test_plugins)
add_dependencies(${OSGI_UI_APP} ${_ctk_test_plugins})
add_dependencies(BlueBerry ${OSGI_UI_APP})
set_property(TARGET ${OSGI_UI_APP} APPEND PROPERTY LABELS BlueBerry)
endif()
configure_file(src/application/solstice.ini
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_UI_APP}.ini)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/berryConfig.h.in" "${CMAKE_CURRENT_BINARY_DIR}/berryConfig.h" @ONLY)
-
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/application/berryStarter.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/src/application/berryStarter.cpp
index aaf3efd660..edf3f318ee 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/application/berryStarter.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/application/berryStarter.cpp
@@ -1,229 +1,210 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLog.h"
#include "berryStarter.h"
#include "berryPlatform.h"
#include "internal/berryInternalPlatform.h"
#include
#include
-//#include
#include
#include
#include
#include
namespace berry
{
const QString Starter::XP_APPLICATIONS = "org.blueberry.osgi.applications";
int Starter::Run(int& argc, char** argv,
Poco::Util::AbstractConfiguration* config)
{
// The CTK PluginFramework needs a QCoreApplication
if (!qApp)
{
BERRY_FATAL << "No QCoreApplication instance found. You need to create one prior to calling Starter::Run()";
}
InternalPlatform* platform = InternalPlatform::GetInstance();
int returnCode = 0;
// startup the internal platform
try
{
platform->Initialize(argc, argv, config);
}
// the Initialize call can throw exceptions so catch them properly
- catch( const berry::PlatformException &e)
+ catch( const std::exception& e)
{
BERRY_ERROR << "Caught exception while initializing the Platform : " << e.what();
BERRY_FATAL << "Platform initialization failed. Aborting... \n";
return 1;
}
platform->Launch();
bool consoleLog = platform->ConsoleLog();
// Add search paths for Qt plugins
foreach(QString qtPluginPath, Platform::GetProperty(Platform::PROP_QTPLUGIN_PATH).split(';', QString::SkipEmptyParts))
{
if (QFile::exists(qtPluginPath))
{
QCoreApplication::addLibraryPath(qtPluginPath);
}
else if (consoleLog)
{
BERRY_WARN << "Qt plugin path does not exist: " << qtPluginPath.toStdString();
}
}
// Add a default search path. It is assumed that installed applications
// provide their Qt plugins in that path.
static const QString defaultQtPluginPath = QCoreApplication::applicationDirPath() + "/plugins";
if (QFile::exists(defaultQtPluginPath))
{
QCoreApplication::addLibraryPath(defaultQtPluginPath);
}
if (consoleLog)
{
std::string pathList;
foreach(QString libPath, QCoreApplication::libraryPaths())
{
pathList += (pathList.empty() ? "" : ", ") + libPath.toStdString();
}
BERRY_INFO << "Qt library search paths: " << pathList;
}
// run the application
IExtensionRegistry* service = platform->GetExtensionRegistry();
if (service == 0)
{
std::string msg = "The extension point service could not be retrieved. This usually indicates that the org.blueberry.core.runtime plug-in could not be loaded.";
platform->GetLogger()->log(
Poco::Message(
"Starter",
msg,
Poco::Message::PRIO_FATAL));
BERRY_FATAL << msg;
returnCode = 1;
}
else
{
QList extensions(
service->GetConfigurationElementsFor(Starter::XP_APPLICATIONS));
QList::iterator iter;
for (iter = extensions.begin(); iter != extensions.end();)
{
if ((*iter)->GetName() != "application")
iter = extensions.erase(iter);
else
++iter;
}
std::string argApplication = Platform::GetConfiguration().getString(
Platform::ARG_APPLICATION.toStdString(), "");
IApplication* app = 0;
if (extensions.size() == 0)
{
BERRY_FATAL
<< "No extensions configured into extension-point '" << Starter::XP_APPLICATIONS << "' found. Aborting.\n";
returnCode = 0;
}
else if (extensions.size() == 1)
{
if (!argApplication.empty())
BERRY_INFO(consoleLog)
<< "One '" << Starter::XP_APPLICATIONS << "' extension found, ignoring "
<< Platform::ARG_APPLICATION << " argument.\n";
QList runs(
extensions[0]->GetChildren("run"));
app = runs.front()->CreateExecutableExtension("class");
- if (app == 0)
- {
-// // support legacy BlueBerry extensions
-// if (IConfigurationElementLegacy* legacyConfigElement =
-// dynamic_cast(runs.front().GetPointer()))
-// {
-// app = legacyConfigElement->CreateExecutableExtension ("class", IApplication::GetManifestName());
-// }
- }
}
else
{
if (argApplication.empty())
{
BERRY_WARN << "You must provide an application id via \""
<< Platform::ARG_APPLICATION << "=\"";
BERRY_INFO << "Possible application ids are:";
for (iter = extensions.begin(); iter != extensions.end(); ++iter)
{
QString appid = (*iter)->GetAttribute("id");
if (!appid.isEmpty())
{
BERRY_INFO << appid.toStdString();
}
}
returnCode = 0;
}
else
{
for (iter = extensions.begin(); iter != extensions.end(); ++iter)
{
BERRY_INFO(consoleLog) << "Checking applications extension from: "
<< (*iter)->GetContributor()->GetName().toStdString() << std::endl;
QString appid = (*iter)->GetAttribute("id");
if (!appid.isNull())
{
BERRY_INFO(consoleLog) << "Found id: " << appid.toStdString() << std::endl;
if (!appid.isEmpty() && appid == QString::fromStdString(argApplication))
{
QList runs((*iter)->GetChildren("run"));
app = runs.front()->CreateExecutableExtension("class");
-// if (app == 0)
-// {
-// // try legacy BlueBerry extensions
-// if (IConfigurationElementLegacy* legacyConfigElement =
-// dynamic_cast(runs.front().GetPointer()))
-// {
-// app = legacyConfigElement->CreateExecutableExtension ("class", IApplication::GetManifestName());
-// }
-// }
break;
}
}
else
{
BERRY_ERROR << "missing attribute: id";
}
}
}
}
if (app == 0)
{
BERRY_ERROR
<< "Could not create executable application extension for id: "
<< argApplication << std::endl;
returnCode = 1;
}
else
{
returnCode = app->Start();
delete app;
}
}
platform->Shutdown();
return returnCode;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferences.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferences.h
index dc14cf7ea9..9dcd078b9f 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferences.h
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryIPreferences.h
@@ -1,705 +1,705 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIPREFERENCES_H_
#define BERRYIPREFERENCES_H_
#include
#include "berryObject.h"
#include "berryBackingStoreException.h"
namespace berry
{
/**
* A node in a hierarchical collection of preference data.
*
*
* This interface allows applications to store and retrieve user and system
* preference data. This data is stored persistently in an
* implementation-dependent backing store. Typical implementations include flat
* files, OS-specific registries, directory servers and SQL databases.
*
*
* For each bundle, there is a separate tree of nodes for each user, and one for
* system preferences. The precise description of "user" and "system" will vary
* from one bundle to another. Typical information stored in the user preference
* tree might include font choice, and color choice for a bundle which interacts
* with the user via a servlet. Typical information stored in the system
* preference tree might include installation data, or things like high score
* information for a game program.
*
*
* Nodes in a preference tree are named in a similar fashion to directories in a
* hierarchical file system. Every node in a preference tree has a node name
* (which is not necessarily unique), a unique absolute path name ,
* and a path name relative to each ancestor including itself.
*
*
* The root node has a node name of the empty QString
object ("").
* Every other node has an arbitrary node name, specified at the time it is
* created. The only restrictions on this name are that it cannot be the empty
* string, and it cannot contain the slash character ('/').
*
*
* The root node has an absolute path name of "/"
. Children of the
* root node have absolute path names of "/" +
<node name>
* . All other nodes have absolute path names of <parent's absolute
* path name> + "/" +
<node name> . Note that
* all absolute path names begin with the slash character.
*
*
* A node n 's path name relative to its ancestor a is simply the
* string that must be appended to a 's absolute path name in order to
* form n 's absolute path name, with the initial slash character (if
* present) removed. Note that:
*
* - No relative path names begin with the slash character.
*
- Every node's path name relative to itself is the empty string.
*
- Every node's path name relative to its parent is its node name (except
* for the root node, which does not have a parent).
*
- Every node's path name relative to the root is its absolute path name
* with the initial slash character removed.
*
*
*
* Note finally that:
*
* - No path name contains multiple consecutive slash characters.
*
- No path name with the exception of the root's absolute path name end in
* the slash character.
*
- Any string that conforms to these two rules is a valid path name.
*
*
*
* Each Preference
node has zero or more properties associated with
* it, where a property consists of a name and a value. The bundle writer is
* free to choose any appropriate names for properties. Their values can be of
* type QString
,long
,int
,bool
,
* std::vector
,float
, or double
but they can
* always be accessed as if they were QString
objects.
*
*
* All node name and property name comparisons are case-sensitive.
*
*
* All of the methods that modify preference data are permitted to operate
* asynchronously; they may return immediately, and changes will eventually
* propagate to the persistent backing store, with an implementation-dependent
* delay. The flush
method may be used to synchronously force updates
* to the backing store.
*
*
* Implementations must automatically attempt to flush to the backing store any
* pending updates for a bundle's preferences when the bundle is stopped or
* otherwise ungets the IPreferences Service.
*
*
* The methods in this class may be invoked concurrently by multiple threads in
* a single Java Virtual Machine (JVM) without the need for external
* synchronization, and the results will be equivalent to some serial execution.
* If this class is used concurrently by multiple JVMs that store their
* preference data in the same backing store, the data store will not be
* corrupted, but no other guarantees are made concerning the consistency of the
* preference data.
*
*
* @version $Revision$
*/
struct org_blueberry_core_runtime_EXPORT IPreferences : virtual public Object
{
berryObjectMacro(berry::IPreferences)
virtual ~IPreferences();
/**
* Associates the specified value with the specified key in this node.
*
* @param key key with which the specified value is to be associated.
* @param value value to be associated with the specified key.
* @throws NullPointerException if key
or value
is
* null
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
*/
virtual void Put(const QString& key, const QString& value) = 0;
/**
* Returns the value associated with the specified key
in this
* node. Returns the specified default if there is no value associated with
* the key
, or the backing store is inaccessible.
*
* @param key key whose associated value is to be returned.
* @param def the value to be returned in the event that this node has no
* value associated with key
or the backing store is
* inaccessible.
* @return the value associated with key
, or def
if
* no value is associated with key
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @throws NullPointerException if key
is null
. (A
* null
default is permitted.)
*/
virtual QString Get(const QString& key, const QString& def) const = 0;
/**
* Removes the value associated with the specified key
in this
* node, if any.
*
* @param key key whose mapping is to be removed from this node.
* @see #get(const QString&,const QString&)
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
*/
virtual void Remove(const QString& key) = 0;
/**
* Removes all of the properties (key-value associations) in this node. This
* call has no effect on any descendants of this node.
*
* @throws BackingStoreException if this operation cannot be completed due
* to a failure in the backing store, or inability to communicate
* with it.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #remove(const QString&)
*/
virtual void Clear() = 0;
/**
* Associates a QString
object representing the specified
* int
value with the specified key
in this node. The
* associated string is the one that would be returned if the int
* value were passed to Integer.toString(int)
. This method is
* intended for use in conjunction with {@link #getInt}method.
*
*
* Implementor's note: it is not necessary that the property value
* be represented by a QString
object in the backing store. If the
* backing store supports integer values, it is not unreasonable to use
* them. This implementation detail is not visible through the
* IPreferences
API, which allows the value to be read as an
* int
(with getInt
or a QString
(with
* get
) type.
*
* @param key key with which the string form of value is to be associated.
* @param value value
whose string form is to be associated with
* key
.
* @throws NullPointerException if key
is null
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #getInt(const QString&,int)
*/
virtual void PutInt(const QString& key, int value) = 0;
/**
* Returns the int
value represented by the QString
* object associated with the specified key
in this node. The
* QString
object is converted to an int
as by
* Integer.parseInt(QString)
. Returns the specified default if
* there is no value associated with the key
, the backing store
* is inaccessible, or if Integer.parseInt(QString)
would throw a
* NumberFormatException
if the associated value
were
* passed. This method is intended for use in conjunction with the
* {@link #putInt}method.
*
* @param key key whose associated value is to be returned as an
* int
.
* @param def the value to be returned in the event that this node has no
* value associated with key
or the associated value
* cannot be interpreted as an int
or the backing store is
* inaccessible.
* @return the int
value represented by the QString
* object associated with key
in this node, or
* def
if the associated value does not exist or cannot
* be interpreted as an int
type.
* @throws NullPointerException if key
is null
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #putInt(const QString&,int)
* @see #get(const QString&,const QString&)
*/
virtual int GetInt(const QString& key, int def) const = 0;
/**
* Associates a QString
object representing the specified
* long
value with the specified key
in this node. The
* associated QString
object is the one that would be returned if
* the long
value were passed to Long.toString(long)
.
* This method is intended for use in conjunction with the {@link #getLong}
* method.
*
*
* Implementor's note: it is not necessary that the value
* be represented by a QString
type in the backing store. If the
* backing store supports long
values, it is not unreasonable to
* use them. This implementation detail is not visible through the
* IPreferences
API, which allows the value to be read as a
* long
(with getLong
or a QString
(with
* get
) type.
*
* @param key key
with which the string form of value
* is to be associated.
* @param value value
whose string form is to be associated with
* key
.
* @throws NullPointerException if key
is null
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #getLong(const QString&,long)
*/
virtual void PutLong(const QString& key, long value) = 0;
/**
* Returns the long
value represented by the QString
* object associated with the specified key
in this node. The
* QString
object is converted to a long
as by
* Long.parseLong(QString)
. Returns the specified default if
* there is no value associated with the key
, the backing store
* is inaccessible, or if Long.parseLong(QString)
would throw a
* NumberFormatException
if the associated value
were
* passed. This method is intended for use in conjunction with the
* {@link #putLong}method.
*
* @param key key
whose associated value is to be returned as a
* long
value.
* @param def the value to be returned in the event that this node has no
* value associated with key
or the associated value
* cannot be interpreted as a long
type or the backing
* store is inaccessible.
* @return the long
value represented by the QString
* object associated with key
in this node, or
* def
if the associated value does not exist or cannot
* be interpreted as a long
type.
* @throws NullPointerException if key
is null
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #putLong(const QString&,long)
* @see #get(const QString&,const QString&)
*/
virtual long GetLong(const QString& key, long def) const = 0;
/**
* Associates a QString
object representing the specified
* bool
value with the specified key in this node. The
* associated string is "true" if the value is true
, and "false"
* if it is false
. This method is intended for use in
* conjunction with the {@link #getBool}method.
*
*
* Implementor's note: it is not necessary that the value be
* represented by a string in the backing store. If the backing store
* supports bool
values, it is not unreasonable to use them.
* This implementation detail is not visible through the IPreferences
*
API, which allows the value to be read as a bool
* (with getBool
) or a QString
(with get
)
* type.
*
* @param key key
with which the string form of value is to be
* associated.
* @param value value whose string form is to be associated with
* key
.
* @throws NullPointerException if key
is null
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #getBool(const QString&,bool)
* @see #get(const QString&,const QString&)
*/
virtual void PutBool(const QString& key, bool value) = 0;
/**
* Returns the bool
value represented by the QString
* object associated with the specified key
in this node. Valid
* strings are "true", which represents true
, and "false", which
* represents false
. Case is ignored, so, for example, "TRUE"
* and "False" are also valid. This method is intended for use in
* conjunction with the {@link #putBool}method.
*
*
* Returns the specified default if there is no value associated with the
* key
, the backing store is inaccessible, or if the associated
* value is something other than "true" or "false", ignoring case.
*
* @param key key
whose associated value is to be returned as a
* bool
.
* @param def the value to be returned in the event that this node has no
* value associated with key
or the associated value
* cannot be interpreted as a bool
or the backing store
* is inaccessible.
* @return the bool
value represented by the std::string
* object associated with key
in this node, or
* null
if the associated value does not exist or cannot
* be interpreted as a bool
.
* @throws NullPointerException if key
is null
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #get(const QString&,const QString&)
* @see #putBool(const QString&,bool)
*/
virtual bool GetBool(const QString& key, bool def) const = 0;
/**
* Associates a QString
object representing the specified
* float
value with the specified key
in this node.
* The associated QString
object is the one that would be returned
* if the float
value were passed to
* Float.toString(float)
. This method is intended for use in
* conjunction with the {@link #getFloat}method.
*
*
* Implementor's note: it is not necessary that the value be
* represented by a string in the backing store. If the backing store
* supports float
values, it is not unreasonable to use them.
* This implementation detail is not visible through the IPreferences
*
API, which allows the value to be read as a float
(with
* getFloat
) or a QString
(with get
) type.
*
* @param key key
with which the string form of value is to be
* associated.
* @param value value whose string form is to be associated with
* key
.
* @throws NullPointerException if key
is null
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #getFloat(const QString&,float)
*/
virtual void PutFloat(const QString& key, float value) = 0;
/**
* Returns the float value
represented by the QString
* object associated with the specified key
in this node. The
* QString
object is converted to a float
value as by
* Float.parseFloat(QString)
. Returns the specified default if
* there is no value associated with the key
, the backing store
* is inaccessible, or if Float.parseFloat(QString)
would throw a
* NumberFormatException
if the associated value were passed.
* This method is intended for use in conjunction with the {@link #putFloat}
* method.
*
* @param key key
whose associated value is to be returned as a
* float
value.
* @param def the value to be returned in the event that this node has no
* value associated with key
or the associated value
* cannot be interpreted as a float
type or the backing
* store is inaccessible.
* @return the float
value represented by the string associated
* with key
in this node, or def
if the
* associated value does not exist or cannot be interpreted as a
* float
type.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @throws NullPointerException if key
is null
.
* @see #putFloat(const QString&,float)
* @see #get(const QString&,const QString&)
*/
virtual float GetFloat(const QString& key, float def) const = 0;
/**
* Associates a QString
object representing the specified
* double
value with the specified key
in this node.
* The associated QString
object is the one that would be returned
* if the double
value were passed to
* Double.toString(double)
. This method is intended for use in
* conjunction with the {@link #getDouble}method
*
*
* Implementor's note: it is not necessary that the value be
* represented by a string in the backing store. If the backing store
* supports double
values, it is not unreasonable to use them.
* This implementation detail is not visible through the IPreferences
*
API, which allows the value to be read as a double
(with
* getDouble
) or a QString
(with get
)
* type.
*
* @param key key
with which the string form of value is to be
* associated.
* @param value value whose string form is to be associated with
* key
.
* @throws NullPointerException if key
is null
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #getDouble(const QString&,double)
*/
virtual void PutDouble(const QString& key, double value) = 0;
/**
* Returns the double
value represented by the QString
* object associated with the specified key
in this node. The
* QString
object is converted to a double
value as by
* Double.parseDouble(QString)
. Returns the specified default if
* there is no value associated with the key
, the backing store
* is inaccessible, or if Double.parseDouble(QString)
would throw
* a NumberFormatException
if the associated value were passed.
* This method is intended for use in conjunction with the
* {@link #putDouble}method.
*
* @param key key
whose associated value is to be returned as a
* double
value.
* @param def the value to be returned in the event that this node has no
* value associated with key
or the associated value
* cannot be interpreted as a double
type or the backing
* store is inaccessible.
* @return the double
value represented by the QString
* object associated with key
in this node, or
* def
if the associated value does not exist or cannot
* be interpreted as a double
type.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the the {@link #removeNode()}method.
* @throws NullPointerException if key
is null
.
* @see #putDouble(const QString&,double)
* @see #get(const QString&,const QString&)
*/
virtual double GetDouble(const QString& key, double def) const = 0;
/**
* Associates a QByteArray
object representing the specified
* QByteArray
with the specified key
in this node. The
* associated QByteArray
object is stored in Base64 encoding.
* This method is intended for use in conjunction with the
* {@link #getByteArray}method.
*
* @param key key
with which the string form of value
* is to be associated.
* @param value value
whose string form is to be associated with
* key
.
* @throws NullPointerException if key
or value
is
* null
.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #GetByteArray(const QString&,const QByteArray&)
* @see #Get(const QString&,const QString&)
*/
virtual void PutByteArray(const QString& key, const QByteArray& value) = 0;
/**
- * Returns the std::vector
value represented by the QString
+ * Returns the QByteArray
value represented by the QString
* object associated with the specified key
in this node. Valid
* QString
objects are Base64 encoded binary data, as
* defined in RFC 2045 ,
* Section 6.8, with one minor change: the string must consist solely of
* characters from the Base64 Alphabet ; no newline characters or
* extraneous characters are permitted. This method is intended for use in
* conjunction with the {@link #putByteArray}method.
*
*
* Returns the specified default if there is no value associated with the
* key
, the backing store is inaccessible, or if the associated
* value is not a valid Base64 encoded byte array (as defined above).
*
* @param key key
whose associated value is to be returned as a
* std::vector
object.
* @param def the value to be returned in the event that this node has no
* value associated with key
or the associated value
* cannot be interpreted as a std::vector
type, or the backing
* store is inaccessible.
* @return the std::vector
value represented by the QString
* object associated with key
in this node, or
* def
if the associated value does not exist or cannot
* be interpreted as a std::vector
.
* @throws NullPointerException if key
is null
. (A
* null
value for def
is permitted.)
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #get(const QString&,const QString&)
* @see #putByteArray(const QString&,std::vector)
*/
virtual QByteArray GetByteArray(const QString& key, const QByteArray& def) const = 0;
/**
* Returns all of the keys that have an associated value in this node. (The
* returned array will be of size zero if this node has no preferences and
* not null
!)
*
* @return an array of the keys that have an associated value in this node.
* @throws BackingStoreException if this operation cannot be completed due
* to a failure in the backing store, or inability to communicate
* with it.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
*/
virtual QStringList Keys() const = 0;
/**
* Returns the names of the children of this node. (The returned array will
* be of size zero if this node has no children and not null
!)
*
* @return the names of the children of this node.
* @throws BackingStoreException if this operation cannot be completed due
* to a failure in the backing store, or inability to communicate
* with it.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
*/
virtual QStringList ChildrenNames() const = 0;
/**
* Returns the parent of this node, or null
if this is the root.
*
* @return the parent of this node.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
*/
virtual IPreferences::Pointer Parent() const = 0;
/**
* Returns a named IPreferences
object (node), creating it and any
* of its ancestors if they do not already exist. Accepts a relative or
* absolute pathname. Absolute pathnames (which begin with '/'
)
* are interpreted relative to the root of this node. Relative pathnames
* (which begin with any character other than '/'
) are
* interpreted relative to this node itself. The empty string (""
)
* is a valid relative pathname, referring to this node itself.
*
*
* If the returned node did not exist prior to this call, this node and any
* ancestors that were created by this call are not guaranteed to become
* persistent until the flush
method is called on the returned
* node (or one of its descendants).
*
* @param pathName the path name of the IPreferences
object to
* return.
* @return the specified IPreferences
object.
* @throws IllegalArgumentException if the path name is invalid.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @throws NullPointerException if path name is null
.
* @see #flush()
*/
virtual IPreferences::Pointer Node(const QString& pathName) = 0;
/**
* Returns true if the named node exists. Accepts a relative or absolute
* pathname. Absolute pathnames (which begin with '/'
) are
* interpreted relative to the root of this node. Relative pathnames (which
* begin with any character other than '/'
) are interpreted
* relative to this node itself. The pathname ""
is valid, and
* refers to this node itself.
*
*
* If this node (or an ancestor) has already been removed with the
* {@link #removeNode()}method, it is legal to invoke this method,
* but only with the pathname ""
; the invocation will return
* false
. Thus, the idiom p.nodeExists("")
may be
* used to test whether p
has been removed.
*
* @param pathName the path name of the node whose existence is to be
* checked.
* @return true if the specified node exists.
* @throws BackingStoreException if this operation cannot be completed due
* to a failure in the backing store, or inability to communicate
* with it.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method and
* pathname
is not the empty string (""
).
* @throws IllegalArgumentException if the path name is invalid (i.e., it
* contains multiple consecutive slash characters, or ends with a
* slash character and is more than one character long).
*/
virtual bool NodeExists(const QString& pathName) const = 0;
/**
* Removes this node and all of its descendants, invalidating any properties
* contained in the removed nodes. Once a node has been removed, attempting
* any method other than name()
,absolutePath()
or
* nodeExists("")
on the corresponding IPreferences
* instance will fail with an IllegalStateException
. (The
* methods defined on Object
can still be invoked on a node after
* it has been removed; they will not throw IllegalStateException
.)
*
*
* The removal is not guaranteed to be persistent until the flush
* method is called on the parent of this node.
*
* @throws IllegalStateException if this node (or an ancestor) has already
* been removed with the {@link #removeNode()}method.
* @throws BackingStoreException if this operation cannot be completed due
* to a failure in the backing store, or inability to communicate
* with it.
* @see #flush()
*/
virtual void RemoveNode() throw(Poco::Exception, BackingStoreException) = 0;
/**
* Returns this node's name, relative to its parent.
*
* @return this node's name, relative to its parent.
*/
virtual QString Name() const = 0;
/**
* Returns this node's absolute path name. Note that:
*
* - Root node - The path name of the root node is
"/"
.
* - Slash at end - Path names other than that of the root node may not
* end in slash (
'/'
).
* - Unusual names -
"."
and ".."
have no
* special significance in path names.
* - Illegal names - The only illegal path names are those that contain
* multiple consecutive slashes, or that end in slash and are not the root.
*
*
* @return this node's absolute path name.
*/
virtual QString AbsolutePath() const = 0;
/**
* Forces any changes in the contents of this node and its descendants to
* the persistent store.
*
*
* Once this method returns successfully, it is safe to assume that all
* changes made in the subtree rooted at this node prior to the method
* invocation have become permanent.
*
*
* Implementations are free to flush changes into the persistent store at
* any time. They do not need to wait for this method to be called.
*
*
* When a flush occurs on a newly created node, it is made persistent, as
* are any ancestors (and descendants) that have yet to be made persistent.
* Note however that any properties value changes in ancestors are not
* guaranteed to be made persistent.
*
* @throws BackingStoreException if this operation cannot be completed due
* to a failure in the backing store, or inability to communicate
* with it.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #sync()
*/
virtual void Flush() = 0;
/**
* Ensures that future reads from this node and its descendants reflect any
* changes that were committed to the persistent store (from any VM) prior
* to the sync
invocation. As a side-effect, forces any changes
* in the contents of this node and its descendants to the persistent store,
* as if the flush
method had been invoked on this node.
*
* @throws BackingStoreException if this operation cannot be completed due
* to a failure in the backing store, or inability to communicate
* with it.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()}method.
* @see #flush()
*/
virtual void Sync() = 0;
};
} // namespace berry
#endif /*BERRYIPREFERENCES_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryMacros.h b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryMacros.h
index d1b6d06d7c..2dc5b376ea 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryMacros.h
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/berryMacros.h
@@ -1,73 +1,41 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef __BERRY_MACROS_H__
#define __BERRY_MACROS_H__
#include "berryWeakPointer.h"
#include "berryExtensionType.h"
#define berryObjectMacro(className) \
typedef className Self; \
typedef berry::SmartPointer Pointer; \
typedef berry::SmartPointer ConstPointer; \
typedef berry::WeakPointer WeakPtr; \
typedef berry::WeakPointer ConstWeakPtr; \
static const char* GetStaticClassName() \
{ return #className; }
-
-/*
-#define berryNewMacro(x) \
-static Pointer New(void) \
-{ \
- Pointer smartPtr(new x); \
- return smartPtr; \
-} \
-
-#define berryNewMacro1Param(x, type1) \
-static Pointer New(type1 param1) \
-{ \
- Pointer smartPtr(new x(param1)); \
- return smartPtr; \
-} \
-
-#define berryNewMacro2Param(x, type1, type2) \
-static Pointer New(type1 param1, type2 param2) \
-{ \
- Pointer smartPtr(new x(param1, param2)); \
- return smartPtr; \
-} \
-
-#define berryNewMacro3Param(x, type1, type2, type3) \
-static Pointer New(type1 param1, type2 param2, type3 param3) \
-{ \
- Pointer smartPtr (new x(param1, param2, param3)); \
- return smartPtr; \
-}
-*/
-
-
#define BERRY_REGISTER_EXTENSION_CLASS(_ClassType, _PluginContext)\
{\
QString typeName = _PluginContext->getPlugin()->getSymbolicName();\
typeName = (typeName + "_") + _ClassType::staticMetaObject.className();\
::berry::registerExtensionType<_ClassType>(typeName.toLatin1().data());\
}
#endif /*__BERRY_MACROS_H__*/
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryInternalPlatform.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryInternalPlatform.cpp
index 1e4f10f13a..751969f15f 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryInternalPlatform.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryInternalPlatform.cpp
@@ -1,597 +1,597 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include "berryInternalPlatform.h"
#include "berryLog.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "berryPlatform.h"
#include "berryPlatformException.h"
#include "berryDebugUtil.h"
//#include "event/berryPlatformEvents.h"
//#include "berryPlatformLogChannel.h"
#include "berryProvisioningInfo.h"
#include "berryCTKPluginActivator.h"
#include "berryLogImpl.h"
#include
#include
#include
#include
#include
namespace berry {
Poco::Mutex InternalPlatform::m_Mutex;
InternalPlatform::InternalPlatform()
: m_Initialized(false)
, m_Running(false)
, m_ConsoleLog(false)
, m_PlatformLogger(0)
, m_ctkPluginFrameworkFactory(0)
{
}
InternalPlatform::~InternalPlatform()
{
}
InternalPlatform* InternalPlatform::GetInstance()
{
Poco::Mutex::ScopedLock lock(m_Mutex);
static InternalPlatform instance;
return &instance;
}
bool InternalPlatform::ConsoleLog() const
{
return m_ConsoleLog;
}
ctkPluginContext* InternalPlatform::GetCTKPluginFrameworkContext() const
{
if (m_ctkPluginFrameworkFactory)
{
return m_ctkPluginFrameworkFactory->getFramework()->getPluginContext();
}
return 0;
}
IAdapterManager* InternalPlatform::GetAdapterManager() const
{
AssertInitialized();
return NULL;
}
void InternalPlatform::Initialize(int& argc, char** argv, Poco::Util::AbstractConfiguration* config)
{
// initialization
Poco::Mutex::ScopedLock lock(m_Mutex);
m_Argc = &argc;
m_Argv = argv;
try
{
this->init(argc, argv);
}
catch (const Poco::Util::UnknownOptionException& e)
{
BERRY_WARN << e.displayText();
}
this->loadConfiguration();
if (config)
{
this->config().add(config, 50, false);
}
m_ConsoleLog = this->GetConfiguration().hasProperty(Platform::ARG_CONSOLELOG.toStdString());
m_ConfigPath.setPath(QString::fromStdString(this->GetConfiguration().getString("application.configDir")));
m_InstancePath.setPath(QString::fromStdString(this->GetConfiguration().getString("application.dir")));
try
{
m_InstallPath.setPath(QString::fromStdString(this->GetConfiguration().getString(Platform::ARG_HOME.toStdString())));
}
catch (Poco::NotFoundException& )
{
m_InstallPath = m_InstancePath;
}
if (this->GetConfiguration().hasProperty(Platform::ARG_STORAGE_DIR.toStdString()))
{
QString dataLocation = QString::fromStdString(this->GetConfiguration().getString(Platform::ARG_STORAGE_DIR.toStdString(), ""));
if (dataLocation.at(dataLocation.size()-1) != '/')
{
dataLocation += '/';
}
m_UserPath.setPath(dataLocation);
}
else
{
// Append a hash value of the absolute path of the executable to the data location.
// This allows to start the same application from different build or install trees.
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + '_';
#else
QString dataLocation = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + '_';
#endif
dataLocation += QString::number(qHash(QCoreApplication::applicationDirPath())) + "/";
m_UserPath.setPath(dataLocation);
}
BERRY_INFO(m_ConsoleLog) << "Framework storage dir: " << m_UserPath.absolutePath();
QFileInfo userFile(m_UserPath.absolutePath());
if (!QDir().mkpath(userFile.absoluteFilePath()) || !userFile.isWritable())
{
QString tmpPath = QDir::temp().absoluteFilePath(QString::fromStdString(this->commandName()));
BERRY_WARN << "Storage dir " << userFile.absoluteFilePath() << " is not writable. Falling back to temporary path " << tmpPath;
QDir().mkpath(tmpPath);
userFile.setFile(tmpPath);
}
// Initialize the CTK Plugin Framework
ctkProperties fwProps;
fwProps.insert(ctkPluginConstants::FRAMEWORK_STORAGE, userFile.absoluteFilePath());
if (this->GetConfiguration().hasProperty(Platform::ARG_CLEAN.toStdString()))
{
fwProps.insert(ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN, ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
}
if (this->GetConfiguration().hasProperty(Platform::ARG_CONSOLELOG.toStdString()))
{
fwProps.insert("org.commontk.pluginfw.debug.framework", true);
fwProps.insert("org.commontk.pluginfw.debug.errors", true);
fwProps.insert("org.commontk.pluginfw.debug.pluginfw", true);
fwProps.insert("org.commontk.pluginfw.debug.lazy_activation", true);
fwProps.insert("org.commontk.pluginfw.debug.resolve", true);
}
if (this->GetConfiguration().hasProperty(Platform::ARG_PRELOAD_LIBRARY.toStdString()))
{
QString preloadLibs = QString::fromStdString(this->GetConfiguration().getString(Platform::ARG_PRELOAD_LIBRARY.toStdString()));
fwProps.insert(ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES, preloadLibs.split(',', QString::SkipEmptyParts));
}
m_ctkPluginFrameworkFactory = new ctkPluginFrameworkFactory(fwProps);
QSharedPointer pfw = m_ctkPluginFrameworkFactory->getFramework();
pfw->init();
ctkPluginContext* pfwContext = pfw->getPluginContext();
// FIXME: This is a quick-fix for Bug 16224 - Umlaut and other special characters in install/binary path
// Assumption : linux provides utf8, windows provides ascii encoded argv lists
#ifdef Q_OS_WIN
QString provisioningFile = QString::fromStdString(this->GetConfiguration().getString(Platform::ARG_PROVISIONING.toStdString()));
#else
- QString provisioningFile = QString::fromUtf8(this->GetConfiguration().getString(Platform::ARG_PROVISIONING.toStdString()));
+ QString provisioningFile = QString::fromUtf8(this->GetConfiguration().getString(Platform::ARG_PROVISIONING.toStdString()).c_str());
#endif
if (!provisioningFile.isEmpty())
{
BERRY_INFO(m_ConsoleLog) << "Using provisioning file: " << provisioningFile;
ProvisioningInfo provInfo(provisioningFile);
// it can still happen, that the encoding is not compatible with the fromUtf8 function ( i.e. when manipulating the LANG variable
// in such case, the QStringList in provInfo is empty which we can easily check for
if( provInfo.getPluginDirs().empty() )
{
BERRY_ERROR << "Cannot search for provisioning file, the retrieved directory list is empty.\n" <<
"This can occur if there are some special (non-ascii) characters in the install path.";
throw berry::PlatformException("No provisioning file specified. Terminating...");
}
foreach(QString pluginPath, provInfo.getPluginDirs())
{
ctkPluginFrameworkLauncher::addSearchPath(pluginPath);
}
bool forcePluginOverwrite = this->GetConfiguration().hasOption(Platform::ARG_FORCE_PLUGIN_INSTALL.toStdString());
QList pluginsToStart = provInfo.getPluginsToStart();
foreach(QUrl pluginUrl, provInfo.getPluginsToInstall())
{
if (forcePluginOverwrite)
{
uninstallPugin(pluginUrl, pfwContext);
}
try
{
BERRY_INFO(m_ConsoleLog) << "Installing CTK plug-in from: " << pluginUrl.toString().toStdString();
QSharedPointer plugin = pfwContext->installPlugin(pluginUrl);
if (pluginsToStart.contains(pluginUrl))
{
m_CTKPluginsToStart << plugin->getPluginId();
}
}
catch (const ctkPluginException& e)
{
QString errorMsg;
QDebug dbg(&errorMsg);
dbg << e.printStackTrace();
BERRY_ERROR << qPrintable(errorMsg);
}
}
}
else
{
BERRY_INFO << "No provisioning file set.";
}
m_BaseStatePath.setPath(m_UserPath.absolutePath() + "/bb-metadata/bb-plugins");
QString logPath(m_UserPath.absoluteFilePath(QString::fromStdString(this->commandName()) + ".log"));
m_PlatformLogChannel = new Poco::SimpleFileChannel(logPath.toStdString());
m_PlatformLogger = &Poco::Logger::create("PlatformLogger", m_PlatformLogChannel, Poco::Message::PRIO_TRACE);
m_Initialized = true;
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
DebugUtil::RestoreState(m_UserPath);
#endif
}
void InternalPlatform::uninstallPugin(const QUrl& pluginUrl, ctkPluginContext* pfwContext)
{
QFileInfo libInfo(pluginUrl.toLocalFile());
QString libName = libInfo.baseName();
if (libName.startsWith("lib"))
{
libName = libName.mid(3);
}
QString symbolicName = libName.replace('_', '.');
foreach(QSharedPointer plugin, pfwContext->getPlugins())
{
if (plugin->getSymbolicName() == symbolicName &&
plugin->getLocation() != pluginUrl.toString())
{
BERRY_WARN << "A plug-in with the symbolic name " << symbolicName.toStdString() <<
" but different location is already installed. Trying to uninstall " << plugin->getLocation().toStdString();
plugin->uninstall();
return;
}
}
}
void InternalPlatform::Launch()
{
AssertInitialized();
if (m_Running) return;
m_Running = true;
this->run();
}
void InternalPlatform::Shutdown()
{
QSharedPointer ctkPluginFW;
{
Poco::Mutex::ScopedLock lock(m_Mutex);
AssertInitialized();
DebugUtil::SaveState(m_UserPath);
ctkPluginFW = m_ctkPluginFrameworkFactory->getFramework();
m_Initialized = false;
}
ctkPluginFW->stop();
this->uninitialize();
// wait 10 seconds for the CTK plugin framework to stop
ctkPluginFW->waitForStop(10000);
}
void InternalPlatform::AssertInitialized() const
{
if (!m_Initialized)
throw Poco::SystemException("The Platform has not been initialized yet!");
}
IExtensionRegistry* InternalPlatform::GetExtensionRegistry()
{
if (m_RegistryTracker.isNull())
{
m_RegistryTracker.reset(new ctkServiceTracker(berry::CTKPluginActivator::getPluginContext()));
m_RegistryTracker->open();
}
return m_RegistryTracker->getService();
}
IPreferencesService *InternalPlatform::GetPreferencesService()
{
if (m_PreferencesTracker.isNull())
{
m_PreferencesTracker.reset(new ctkServiceTracker(berry::CTKPluginActivator::getPluginContext()));
m_PreferencesTracker->open();
}
return m_PreferencesTracker->getService();
}
QDir InternalPlatform::GetConfigurationPath()
{
return m_ConfigPath;
}
QDir InternalPlatform::GetInstallPath()
{
return m_InstallPath;
}
QDir InternalPlatform::GetInstancePath()
{
return m_InstancePath;
}
bool InternalPlatform::GetStatePath(QDir& statePath, const QSharedPointer& plugin, bool create)
{
QFileInfo tmpStatePath(m_BaseStatePath.absoluteFilePath(plugin->getSymbolicName()));
if (tmpStatePath.exists())
{
if (tmpStatePath.isDir() && tmpStatePath.isWritable() && tmpStatePath.isReadable())
{
statePath.setPath(tmpStatePath.absoluteFilePath());
return true;
}
else
{
return false;
}
}
else if (create)
{
bool created = statePath.mkpath(tmpStatePath.absoluteFilePath());
if (created)
{
statePath.setPath(tmpStatePath.absoluteFilePath());
return true;
}
return false;
}
return false;
}
//PlatformEvents& InternalPlatform::GetEvents()
//{
// return m_Events;
//}
QDir InternalPlatform::GetUserPath()
{
return m_UserPath;
}
ILog *InternalPlatform::GetLog(const QSharedPointer &plugin) const
{
LogImpl* result = m_Logs.value(plugin->getPluginId());
if (result != NULL)
return result;
// ExtendedLogService logService = (ExtendedLogService) extendedLogTracker.getService();
// Logger logger = logService == null ? null : logService.getLogger(bundle, PlatformLogWriter.EQUINOX_LOGGER_NAME);
// result = new Log(bundle, logger);
// ExtendedLogReaderService logReader = (ExtendedLogReaderService) logReaderTracker.getService();
// logReader.addLogListener(result, result);
// logs.put(bundle, result);
// return result;
result = new LogImpl(plugin);
m_Logs.insert(plugin->getPluginId(), result);
return result;
}
bool InternalPlatform::IsRunning() const
{
Poco::Mutex::ScopedLock lock(m_Mutex);
return (m_Initialized && m_Running);
}
QSharedPointer InternalPlatform::GetPlugin(const QString &symbolicName)
{
QList > plugins =
InternalPlatform::GetInstance()->GetCTKPluginFrameworkContext()->getPlugins();
QSharedPointer res(0);
foreach(QSharedPointer plugin, plugins)
{
if ((plugin->getState() & (ctkPlugin::INSTALLED | ctkPlugin::UNINSTALLED)) == 0 &&
plugin->getSymbolicName() == symbolicName)
{
if (res.isNull())
{
res = plugin;
}
else if (res->getVersion().compare(plugin->getVersion()) < 0)
{
res = plugin;
}
}
}
return res;
}
QList > InternalPlatform::GetPlugins(const QString &symbolicName, const QString &version)
{
QList > plugins =
InternalPlatform::GetInstance()->GetCTKPluginFrameworkContext()->getPlugins();
QMap > selected;
ctkVersion versionObj(version);
foreach(QSharedPointer plugin, plugins)
{
if ((plugin->getState() & (ctkPlugin::INSTALLED | ctkPlugin::UNINSTALLED)) == 0 &&
plugin->getSymbolicName() == symbolicName)
{
if (plugin->getVersion().compare(versionObj) > -1)
{
selected.insert(plugin->getVersion(), plugin);
}
}
}
QList > sortedPlugins = selected.values();
QList > reversePlugins;
qCopyBackward(sortedPlugins.begin(), sortedPlugins.end(), reversePlugins.end());
return reversePlugins;
}
Poco::Logger* InternalPlatform::GetLogger()
{
return m_PlatformLogger;
}
Poco::Util::LayeredConfiguration& InternalPlatform::GetConfiguration() const
{
return this->config();
}
QStringList InternalPlatform::GetApplicationArgs() const
{
return m_FilteredArgs;
}
int& InternalPlatform::GetRawApplicationArgs(char**& argv)
{
argv = m_Argv;
return *m_Argc;
}
void InternalPlatform::defineOptions(Poco::Util::OptionSet& options)
{
Poco::Util::Option helpOption("help", "h", "print this help text");
helpOption.callback(Poco::Util::OptionCallback(this, &InternalPlatform::PrintHelp));
options.addOption(helpOption);
Poco::Util::Option newInstanceOption(Platform::ARG_NEWINSTANCE.toStdString(), "", "forces a new instance of this application");
newInstanceOption.binding(Platform::ARG_NEWINSTANCE.toStdString());
options.addOption(newInstanceOption);
Poco::Util::Option cleanOption(Platform::ARG_CLEAN.toStdString(), "", "cleans the plugin cache");
cleanOption.binding(Platform::ARG_CLEAN.toStdString());
options.addOption(cleanOption);
Poco::Util::Option appOption(Platform::ARG_APPLICATION.toStdString(), "", "the id of the application extension to be executed");
appOption.argument("").binding(Platform::ARG_APPLICATION.toStdString());
options.addOption(appOption);
Poco::Util::Option storageDirOption(Platform::ARG_STORAGE_DIR.toStdString(), "", "the location for storing persistent application data");
storageDirOption.argument("").binding(Platform::ARG_STORAGE_DIR.toStdString());
options.addOption(storageDirOption);
Poco::Util::Option consoleLogOption(Platform::ARG_CONSOLELOG.toStdString(), "", "log messages to the console");
consoleLogOption.binding(Platform::ARG_CONSOLELOG.toStdString());
options.addOption(consoleLogOption);
Poco::Util::Option forcePluginOption(Platform::ARG_FORCE_PLUGIN_INSTALL.toStdString(), "", "force installing plug-ins with same symbolic name");
forcePluginOption.binding(Platform::ARG_FORCE_PLUGIN_INSTALL.toStdString());
options.addOption(forcePluginOption);
Poco::Util::Option preloadLibsOption(Platform::ARG_PRELOAD_LIBRARY.toStdString(), "", "preload a library");
preloadLibsOption.argument("").repeatable(true).callback(Poco::Util::OptionCallback(this, &InternalPlatform::handlePreloadLibraryOption));
options.addOption(preloadLibsOption);
Poco::Util::Option testPluginOption(Platform::ARG_TESTPLUGIN.toStdString(), "", "the plug-in to be tested");
testPluginOption.argument("").binding(Platform::ARG_TESTPLUGIN.toStdString());
options.addOption(testPluginOption);
Poco::Util::Option testAppOption(Platform::ARG_TESTAPPLICATION.toStdString(), "", "the application to be tested");
testAppOption.argument("").binding(Platform::ARG_TESTAPPLICATION.toStdString());
options.addOption(testAppOption);
Poco::Util::Option noRegistryCacheOption(Platform::ARG_NO_REGISTRY_CACHE.toStdString(), "", "do not use a cache for the registry");
noRegistryCacheOption.binding(Platform::ARG_NO_REGISTRY_CACHE.toStdString());
options.addOption(noRegistryCacheOption);
Poco::Util::Option noLazyRegistryCacheLoadingOption(Platform::ARG_NO_LAZY_REGISTRY_CACHE_LOADING.toStdString(), "", "do not use lazy cache loading for the registry");
noLazyRegistryCacheLoadingOption.binding(Platform::ARG_NO_LAZY_REGISTRY_CACHE_LOADING.toStdString());
options.addOption(noLazyRegistryCacheLoadingOption);
Poco::Util::Option registryMultiLanguageOption(Platform::ARG_REGISTRY_MULTI_LANGUAGE.toStdString(), "", "enable multi-language support for the registry");
registryMultiLanguageOption.binding(Platform::ARG_REGISTRY_MULTI_LANGUAGE.toStdString());
options.addOption(registryMultiLanguageOption);
Poco::Util::Option xargsOption(Platform::ARG_XARGS.toStdString(), "", "Extended argument list");
xargsOption.argument("").binding(Platform::ARG_XARGS.toStdString());
options.addOption(xargsOption);
Poco::Util::Application::defineOptions(options);
}
void InternalPlatform::handlePreloadLibraryOption(const std::string& /*name*/, const std::string& value)
{
std::string oldVal;
if (this->config().hasProperty(Platform::ARG_PRELOAD_LIBRARY.toStdString()))
{
oldVal = this->config().getString(Platform::ARG_PRELOAD_LIBRARY.toStdString());
}
this->config().setString(Platform::ARG_PRELOAD_LIBRARY.toStdString(), oldVal + "," + value);
}
int InternalPlatform::main(const std::vector& args)
{
for(std::vector::const_iterator i = args.begin(); i != args.end(); ++i)
{
m_FilteredArgs << QString::fromStdString(*i);
}
//m_FilteredArgs.insert(m_FilteredArgs.begin(), this->config().getString("application.argv[0]"));
ctkPluginContext* context = GetCTKPluginFrameworkContext();
QFileInfo storageDir = context->getDataFile("");
m_ctkPluginFrameworkFactory->getFramework()->start();
foreach(long pluginId, m_CTKPluginsToStart)
{
BERRY_INFO(m_ConsoleLog) << "Starting CTK plug-in: " << context->getPlugin(pluginId)->getSymbolicName().toStdString()
<< " [" << pluginId << "]";
// do not change the autostart setting of this plugin
context->getPlugin(pluginId)->start(ctkPlugin::START_TRANSIENT | ctkPlugin::START_ACTIVATION_POLICY);
}
return EXIT_OK;
}
void InternalPlatform::PrintHelp(const std::string&, const std::string&)
{
Poco::Util::HelpFormatter help(this->options());
help.setAutoIndent();
help.setCommand(this->commandName());
help.format(std::cout);
exit(EXIT_OK);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferences.cpp b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferences.cpp
index 07adce79c0..49865b120f 100644
--- a/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferences.cpp
+++ b/BlueBerry/Bundles/org.blueberry.core.runtime/src/internal/berryPreferences.cpp
@@ -1,495 +1,505 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPreferences.h"
#include "berryAbstractPreferencesStorage.h"
#include
#include
namespace berry
{
Preferences::Preferences(const PropertyMap& _Properties
, const QString& _Name
, Preferences* _Parent
, AbstractPreferencesStorage* _Storage)
: m_Properties(_Properties)
, m_Path(_Parent ? _Parent->AbsolutePath() + (_Parent->AbsolutePath() == "/" ? "": "/") + _Name : "/")
, m_Name(_Name)
, m_Parent(_Parent)
, m_Root(_Parent ? _Parent->m_Root : this)
, m_Removed(false)
, m_Storage(_Storage)
{
// root node if parent is 0
if (_Parent != 0)
{
// save as child in parent
_Parent->m_Children.push_back(Preferences::Pointer(this));
}
}
bool Preferences::Has(const QString& key ) const
{
QMutexLocker scopedMutex(&m_Mutex);
return this->Has_unlocked(key);
}
bool Preferences::Has_unlocked(const QString& key ) const
{
return (m_Properties.find(key) != m_Properties.end());
}
bool Preferences::IsDirty() const
{
QMutexLocker scopedMutex(&m_Mutex);
bool dirty = m_Dirty;
for (ChildrenList::const_iterator it = m_Children.begin()
; it != m_Children.end(); ++it)
{
// break condition: if one node is dirty the whole tree is dirty
if(dirty)
break;
else
dirty = (*it)->IsDirty();
}
return dirty;
}
QString Preferences::ToString() const
{
return QString("Preferences[") + m_Path + "]";
}
bool Preferences::Equals(const Preferences* rhs) const
{
if(rhs == 0)
return false;
return (this->m_Path == rhs->m_Path);
}
Preferences::PropertyMap Preferences::GetProperties() const
{
QMutexLocker scopedMutex(&m_Mutex);
return m_Properties;
}
Preferences::ChildrenList Preferences::GetChildren() const
{
QMutexLocker scopedMutex(&m_Mutex);
return m_Children;
}
QString Preferences::AbsolutePath() const
{
return m_Path;
}
QStringList Preferences::ChildrenNames() const
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
QStringList names;
for (ChildrenList::const_iterator it = m_Children.begin()
; it != m_Children.end(); ++it)
{
names.push_back((*it)->Name());
}
return names;
}
AbstractPreferencesStorage* Preferences::GetStorage() const
{
return m_Storage;
}
void Preferences::Clear()
{
- QMutexLocker scopedMutex(&m_Mutex);
- AssertValid_unlocked();
- m_Properties.clear();
- this->SetDirty_unlocked(true);
+ {
+ QMutexLocker scopedMutex(&m_Mutex);
+ AssertValid_unlocked();
+ m_Properties.clear();
+ }
+ this->SetDirty(true);
}
void Preferences::Flush()
{
m_Storage->Flush(this);
// if something is written, make the tree undirty
// there is a race condition here: after flushing, another thread
// could modify this object before we can set dirty to false,
// but we cannot hold a lock before flushing because the operation
// will call other methods on this object, which would lead
// to a recursive lock.
this->SetDirty(false);
}
QString Preferences::Get(const QString& key, const QString& def) const
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
return this->Has_unlocked(key) ? m_Properties[key] : def;
}
bool Preferences::GetBool(const QString& key, bool def) const
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
return this->Has_unlocked(key) ? (m_Properties[key] == "true" ? true: false) : def;
}
QByteArray Preferences::GetByteArray(const QString& key, const QByteArray& def) const
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
return this->Has_unlocked(key) ? QByteArray::fromBase64(m_Properties[key].toLatin1()) : def;
}
double Preferences::GetDouble(const QString& key, double def) const
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
return this->Has_unlocked(key) ? m_Properties[key].toDouble() : def;
}
float Preferences::GetFloat(const QString& key, float def) const
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
return this->Has_unlocked(key) ? m_Properties[key].toFloat() : def;
}
int Preferences::GetInt(const QString& key, int def) const
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
return this->Has_unlocked(key) ? m_Properties[key].toInt() : def;
}
long Preferences::GetLong(const QString& key, long def) const
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
return this->Has_unlocked(key) ? m_Properties[key].toLong() : def;
}
QStringList Preferences::Keys() const
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
return m_Properties.keys();
}
QString Preferences::Name() const
{
return m_Name;
}
IPreferences::Pointer Preferences::Node(const QString& path)
{
QMutexLocker scopedMutex(&m_Mutex);
return this->Node_unlocked(path);
}
Preferences::Pointer Preferences::Node_unlocked(const QString& path)
{
QString pathName = path;
AssertValid_unlocked();
AssertPath_unlocked(pathName);
Preferences::Pointer node;
// self reference
if(pathName == "")
return Preferences::Pointer(this);
// absolute path
else if(pathName[0] == '/')
{
pathName = pathName.mid(1);
// call root with this relative path
if (this == m_Root)
return m_Root->Node_unlocked(pathName);
else
return m_Root->Node(pathName).Cast();
}
// relative path
else
{
// check if pathName contains anymore names
QString name = pathName;
// create new child nodes as long as there are names in the path
int pos = pathName.indexOf('/');
// cut from the beginning
if(pos != -1)
{
name = pathName.left(pos);
pathName = pathName.mid(pos+1);
}
// now check if node exists->if not: make new
for (ChildrenList::iterator it = m_Children.begin()
; it != m_Children.end(); it++)
{
// node found
if((*it)->Name() == name && (*it)->IsRemoved() == false)
{
node = *it;
break;
}
}
// node not found create new one
if(node.IsNull())
{
// the new node automatically pushes itself into the children array of *this*
Preferences::Pointer newNode(new Preferences(PropertyMap(), name, this, m_Storage));
node = newNode.GetPointer();
// this branch is dirty now -> prefs must be rewritten persistently
this->SetDirty_unlocked(true);
}
// call Node() again if there are any names left on the path
if(pos != -1)
{
if (this == node.GetPointer())
node = node->Node_unlocked(pathName);
else
node = node->Node(pathName).Cast();
}
}
return node;
}
bool Preferences::NodeExists(const QString& path) const
{
QString pathName = path;
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
AssertPath_unlocked(pathName);
bool nodeExists = false;
// absolute path
if(pathName[0] == '/')
{
pathName = pathName.mid(1);
// call root with this relative path
return m_Root->NodeExists(pathName);
}
// relative path
else
{
// check if pathName contains anymore names
QString name = pathName;
// create new child nodes as long as there are names in the path
int pos = pathName.indexOf("/");
// cut from the beginning
if(pos != -1)
{
name = pathName.left(pos);
pathName = pathName.mid(pos+1);
}
// now check if node exists->if not: make new
for (ChildrenList::const_iterator it = m_Children.begin()
; it != m_Children.end(); it++)
{
// node found
if((*it)->Name() == name)
{
// call recursively if more names on the path exist
if(pos != -1)
nodeExists = (*it)->NodeExists(pathName);
else
nodeExists = true;
break;
}
}
}
return nodeExists;
}
void Preferences::Put(const QString& key, const QString& value)
{
- QMutexLocker scopedMutex(&m_Mutex);
- AssertValid_unlocked();
+ {
+ QMutexLocker scopedMutex(&m_Mutex);
+ AssertValid_unlocked();
- m_Properties[key] = value;
- this->SetDirty_unlocked(true);
+ m_Properties[key] = value;
+ }
+ this->SetDirty(true);
}
void Preferences::PutByteArray(const QString& key, const QByteArray& value)
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
this->Put(key, value.toBase64().data());
}
void Preferences::PutBool(const QString& key, bool value)
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
this->Put(key, value ? "true" : "false");
}
void Preferences::PutDouble(const QString& key, double value)
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
this->Put(key, QString::number(value));
}
void Preferences::PutFloat(const QString& key, float value)
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
this->Put(key, QString::number(value));
}
void Preferences::PutInt(const QString& key, int value)
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
this->Put(key, QString::number(value));
}
void Preferences::PutLong(const QString& key, long value)
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
this->Put(key, QString::number(value));
}
void Preferences::Remove(const QString& key)
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
PropertyMap::iterator it = m_Properties.find(key);
if(it != m_Properties.end())
m_Properties.erase(it);
}
void Preferences::RemoveNode() throw(Poco::Exception, BackingStoreException)
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
this->SetRemoved_unlocked(true);
m_Parent->m_Children.erase(std::find(m_Parent->m_Children.begin(), m_Parent->m_Children.end(),
Preferences::Pointer(this)));
}
void Preferences::Sync() throw(Poco::Exception, BackingStoreException)
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
this->Flush();
}
void Preferences::AssertValid_unlocked() const
{
if(m_Removed)
{
throw ctkIllegalStateException(QString("no node at '") + m_Path + "'");
}
}
void Preferences::AssertPath_unlocked(const QString& pathName)
{
if(pathName.indexOf("//") != -1)
{
throw ctkInvalidArgumentException(QString("Illegal // in m_Path m_Name '") + pathName + "'");
}
int strLength = pathName.size();
if(strLength > 1 && pathName[strLength-1] == '/')
{
throw ctkInvalidArgumentException(QString("Trailing / in m_Path m_Name '") + pathName + "'");
}
}
IPreferences::Pointer Preferences::Parent() const
{
QMutexLocker scopedMutex(&m_Mutex);
AssertValid_unlocked();
return IPreferences::Pointer(m_Parent);
}
void Preferences::SetDirty( bool _Dirty )
{
- QMutexLocker scopedMutex(&m_Mutex);
- this->SetDirty_unlocked(_Dirty);
+ {
+ QMutexLocker scopedMutex(&m_Mutex);
+ m_Dirty = _Dirty;
+ }
+ if(_Dirty)
+ {
+ this->OnChanged.Send(this);
+ }
}
void Preferences::SetDirty_unlocked( bool _Dirty )
{
m_Dirty = _Dirty;
if(_Dirty)
this->OnChanged.Send(this);
/*
for (ChildrenList::iterator it = m_Children.begin()
; it != m_Children.end(); ++it)
{
(*it)->SetDirty(_Dirty);
}
*/
}
void Preferences::SetRemoved( bool _Removed )
{
QMutexLocker scopedMutex(&m_Mutex);
this->SetRemoved_unlocked(_Removed);
}
void Preferences::SetRemoved_unlocked( bool _Removed )
{
m_Removed = _Removed;
for (ChildrenList::iterator it = m_Children.begin()
; it != m_Children.end(); ++it)
{
(*it)->SetRemoved(_Removed);
}
}
/*
Preferences::ChildrenList& Preferences::GetChildren() const
{
return m_Children;
}*/
bool Preferences::IsRemoved() const
{
QMutexLocker scopedMutex(&m_Mutex);
return m_Removed;
}
Preferences::~Preferences()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.cpp b/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.cpp
index c15a053b6d..149a331d4a 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.cpp
@@ -1,94 +1,95 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryBlueBerryTestDriver.h"
#include "internal/berryTestRegistry.h"
#include "cppunit/TestRunner.h"
#include "cppunit/TestResult.h"
#include "cppunit/TestResultCollector.h"
namespace berry
{
-BlueBerryTestDriver::BlueBerryTestDriver(const std::vector<
- ITestDescriptor::Pointer>& descriptors,
+BlueBerryTestDriver::BlueBerryTestDriver(
+ const QList& descriptors,
bool uitests,
- const std::string& testName,
- bool wait) :
- descriptors(descriptors), uitests(uitests), testName(testName), wait(wait)
+ const QString& testName,
+ bool wait)
+ : descriptors(descriptors)
+ , uitests(uitests)
+ , testName(testName)
+ , wait(wait)
{
}
int BlueBerryTestDriver::Run()
{
CppUnit::TestRunner runner;
unsigned int testCounter = 0;
- for (std::vector::iterator i = descriptors.begin(); i
- != descriptors.end(); ++i)
+ foreach (const ITestDescriptor::Pointer& descr, descriptors)
{
- ITestDescriptor::Pointer descr(*i);
if (descr->IsUITest() == uitests)
{
CppUnit::Test* test = descr->CreateTest();
runner.addTest(test);
++testCounter;
}
}
if (testCounter == 0)
{
std::cout << "No " << (uitests ? "UI " : "") << "tests registered."
<< std::endl;
return 0;
}
/*
std::vector args;
args.push_back("BlueBerryTestDriver");
if (testName.empty())
args.push_back("-all");
else
args.push_back(testName);
if (wait)
args.push_back("-wait");
return runner.run(args) ? 0 : 1;
*/
CppUnit::TestResult controller;
CppUnit::TestResultCollector result;
controller.addListener(&result);
runner.run(controller);
return result.wasSuccessful() ? 0 : 1;
}
-int BlueBerryTestDriver::Run(const std::string& pluginId, bool uitests)
+int BlueBerryTestDriver::Run(const QString& pluginId, bool uitests)
{
TestRegistry testRegistry;
- const std::vector& tests = testRegistry.GetTestsForId(
+ const QList& tests = testRegistry.GetTestsForId(
pluginId);
BlueBerryTestDriver driver(tests, uitests);
return driver.Run();
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h b/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h
index 436ee33856..2336f659c8 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/berryBlueBerryTestDriver.h
@@ -1,55 +1,53 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYBLUEBERRYTESTDRIVER_H_
#define BERRYBLUEBERRYTESTDRIVER_H_
#include
#include "berryITestDescriptor.h"
-#include
-
namespace berry
{
/**
* A TestDriver for CppUnit that supports running tests inside BlueBerry as well as
* running standalone.
* Example call: TODO
*/
class BERRY_TEST_EXPORT BlueBerryTestDriver
{
public:
- BlueBerryTestDriver(const std::vector& descriptors, bool uitests = false, const std::string& testName="", bool wait=false);
+ BlueBerryTestDriver(const QList& descriptors, bool uitests = false, const QString& testName="", bool wait=false);
int Run();
- static int Run(const std::string& pluginId, bool uitests = false);
+ static int Run(const QString& pluginId, bool uitests = false);
protected:
- std::vector descriptors;
+ QList descriptors;
bool uitests;
- std::string testName;
+ QString testName;
bool wait;
};
}
#endif /* BERRYBLUEBERRYTESTDRIVER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp b/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp
index bb716a712b..b7bd360175 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/berryCoreTestApplication.cpp
@@ -1,54 +1,55 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryCoreTestApplication.h"
#include
#include
#include "berryBlueBerryTestDriver.h"
namespace berry {
CoreTestApplication::CoreTestApplication()
{
}
CoreTestApplication::CoreTestApplication(const CoreTestApplication& other)
+ : QObject()
{
Q_UNUSED(other)
}
int CoreTestApplication::Start() {
std::string testPlugin;
try {
- testPlugin = Platform::GetConfiguration().getString(Platform::ARG_TESTPLUGIN);
+ testPlugin = Platform::GetConfiguration().getString(Platform::ARG_TESTPLUGIN.toStdString());
}
catch (const Poco::NotFoundException& /*e*/)
{
BERRY_ERROR << "You must specify a test plug-in id via " << Platform::ARG_TESTPLUGIN << "=";
return 1;
}
- return BlueBerryTestDriver::Run(testPlugin);
+ return BlueBerryTestDriver::Run(QString::fromStdString(testPlugin));
}
void CoreTestApplication::Stop() {
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/berryITestDescriptor.h b/BlueBerry/Bundles/org.blueberry.test/src/berryITestDescriptor.h
index 67540cc46e..84b03d5239 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/berryITestDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/berryITestDescriptor.h
@@ -1,42 +1,42 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYITESTDESCRIPTOR_H_
#define BERRYITESTDESCRIPTOR_H_
#include
#include
#include
namespace berry {
struct ITestDescriptor : public Object
{
berryObjectMacro(berry::ITestDescriptor)
virtual CppUnit::Test* CreateTest() = 0;
- virtual std::string GetId() const = 0;
- virtual std::string GetContributor() const = 0;
- virtual std::string GetDescription() const = 0;
+ virtual QString GetId() const = 0;
+ virtual QString GetContributor() const = 0;
+ virtual QString GetDescription() const = 0;
virtual bool IsUITest() const = 0;
};
}
#endif /* BERRYITESTDESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.cpp b/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.cpp
index fc3b966cae..a4e80f72a8 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.cpp
@@ -1,73 +1,75 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryTestCase.h"
#include
#include
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
#include
#endif
-berry::TestCase::TestCase(const std::string& testName) :
- CppUnit::TestCase(testName), m_LeakDetails(false),
+#include
+
+berry::TestCase::TestCase(const QString& testName) :
+ CppUnit::TestCase(testName.toStdString()), m_LeakDetails(false),
m_IgnoreLeakage(false)
{
}
void berry::TestCase::LeakDetailsOn()
{
m_LeakDetails = true;
}
void berry::TestCase::IgnoreLeakingObjects()
{
BERRY_WARN << "Ignoring Leaking Objects!!";
m_IgnoreLeakage = true;
}
void berry::TestCase::DoSetUp()
{
}
void berry::TestCase::DoTearDown()
{
}
void berry::TestCase::setUp()
{
CppUnit::TestCase::setUp();
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
DebugUtil::ResetObjectSummary();
#endif
DoSetUp();
}
void berry::TestCase::tearDown()
{
CppUnit::TestCase::tearDown();
DoTearDown();
#ifdef BLUEBERRY_DEBUG_SMARTPOINTER
assert(m_IgnoreLeakage || !DebugUtil::PrintObjectSummary(m_LeakDetails));
#endif
m_LeakDetails = false;
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h b/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h
index 4a3dfb6afe..bdb1502010 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/harness/berryTestCase.h
@@ -1,84 +1,84 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYTESTCASE_H_
#define BERRYTESTCASE_H_
#include
#include
namespace berry {
class BERRY_TEST_EXPORT TestCase : public CppUnit::TestCase
{
public:
- TestCase(const std::string& testName);
+ TestCase(const QString& testName);
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
* The default implementation does nothing.
* Subclasses may extend.
*/
virtual void DoSetUp();
/**
* Tears down the fixture, for example, close a network connection.
* This method is called after a test is executed.
* The default implementation closes all test windows, processing events both before
* and after doing so.
* Subclasses may extend.
*/
virtual void DoTearDown();
/**
* Clients should overwrite DoSetUp() instead of this method.
*/
void setUp();
/**
* Clients should overwrite DoSetUp() instead of this method.
*/
void tearDown();
protected:
/**
* Call this method in your unit test to enable detailed
* output about leaking berry::Object instances.
*/
void LeakDetailsOn();
/**
* Call this method to ignore leaking objects and to continue
* with the unit tests.
*/
void IgnoreLeakingObjects();
private:
bool m_LeakDetails;
bool m_IgnoreLeakage;
};
}
#endif /* BERRYTESTCASE_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp
index f6d0a19b0f..4a13f5839b 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryPluginActivator.cpp
@@ -1,45 +1,46 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPluginActivator.h"
+#include "berryMacros.h"
#include "berryCoreTestApplication.h"
#include
namespace berry {
org_blueberry_test_Activator::org_blueberry_test_Activator()
{
}
void org_blueberry_test_Activator::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(CoreTestApplication, context)
}
void org_blueberry_test_Activator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_PLUGIN2(org_blueberry_test, berry::org_blueberry_test_Activator)
#endif
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp
index 6ce4431f59..7e709cd9c3 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.cpp
@@ -1,76 +1,68 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryTestDescriptor.h"
#include "berryTestRegistry.h"
+#include "berryIContributor.h"
#include
Q_DECLARE_INTERFACE(CppUnit::Test, "CppUnit.Test")
namespace berry
{
TestDescriptor::TestDescriptor(IConfigurationElement::Pointer elem) :
configElem(elem)
{
}
CppUnit::Test* TestDescriptor::CreateTest()
{
CppUnit::Test* test = configElem->CreateExecutableExtension (
TestRegistry::ATT_CLASS);
if (test == 0)
{
// Try legacy BlueBerry manifests instead
test = configElem->CreateExecutableExtension (
- TestRegistry::ATT_CLASS, TestRegistry::TEST_MANIFEST);
+ TestRegistry::ATT_CLASS);
}
return test;
}
-std::string TestDescriptor::GetId() const
+QString TestDescriptor::GetId() const
{
- std::string id;
- configElem->GetAttribute(TestRegistry::ATT_ID, id);
- return id;
+ return configElem->GetAttribute(TestRegistry::ATT_ID);
}
-std::string TestDescriptor::GetContributor() const
+QString TestDescriptor::GetContributor() const
{
- return configElem->GetContributor();
+ return configElem->GetContributor()->GetName();
}
-std::string TestDescriptor::GetDescription() const
+QString TestDescriptor::GetDescription() const
{
- std::string descr;
- configElem->GetAttribute(TestRegistry::ATT_DESCRIPTION, descr);
- return descr;
+ return configElem->GetAttribute(TestRegistry::ATT_DESCRIPTION);
}
bool TestDescriptor::IsUITest() const
{
- std::string isUi;
- if (configElem->GetAttribute(TestRegistry::ATT_UITEST, isUi))
- {
- return !Poco::icompare(isUi, "true");
- }
-
- return false;
+ QString isUi = configElem->GetAttribute(TestRegistry::ATT_UITEST);
+ return isUi.compare("true", Qt::CaseInsensitive);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.h b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.h
index 4e766f59de..33ad3ec271 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestDescriptor.h
@@ -1,49 +1,49 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYTESTDESCRIPTOR_H_
#define BERRYTESTDESCRIPTOR_H_
#include "berryITestDescriptor.h"
-#include
+#include
namespace berry {
class TestDescriptor : public ITestDescriptor
{
public:
- berryObjectMacro(TestDescriptor);
+ berryObjectMacro(TestDescriptor)
TestDescriptor(IConfigurationElement::Pointer elem);
CppUnit::Test* CreateTest();
- std::string GetId() const;
- std::string GetContributor() const;
- std::string GetDescription() const;
+ QString GetId() const;
+ QString GetContributor() const;
+ QString GetDescription() const;
bool IsUITest() const;
private:
IConfigurationElement::Pointer configElem;
};
}
#endif /* BERRYTESTDESCRIPTOR_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.cpp b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.cpp
index 9a4734a936..2ef72bacd3 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.cpp
@@ -1,63 +1,60 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryTestRegistry.h"
#include "berryTestDescriptor.h"
#include
-#include
+#include
namespace berry
{
-const std::string TestRegistry::TAG_TEST = "test";
-const std::string TestRegistry::ATT_ID = "id";
-const std::string TestRegistry::ATT_CLASS = "class";
-const std::string TestRegistry::ATT_DESCRIPTION = "description";
-const std::string TestRegistry::ATT_UITEST = "uitest";
-
-const std::string TestRegistry::TEST_MANIFEST = "CppUnitTest";
+const QString TestRegistry::TAG_TEST = "test";
+const QString TestRegistry::ATT_ID = "id";
+const QString TestRegistry::ATT_CLASS = "class";
+const QString TestRegistry::ATT_DESCRIPTION = "description";
+const QString TestRegistry::ATT_UITEST = "uitest";
TestRegistry::TestRegistry()
{
- std::vector elements(
- Platform::GetExtensionPointService()->GetConfigurationElementsFor(
+ QList elements(
+ Platform::GetExtensionRegistry()->GetConfigurationElementsFor(
"org.blueberry.tests"));
- for (std::vector::iterator i =
- elements.begin(); i != elements.end(); ++i)
+ foreach (const IConfigurationElement::Pointer& configElem, elements)
{
- if ((*i)->GetName() == TAG_TEST)
+ if (configElem->GetName() == TAG_TEST)
{
- this->ReadTest(*i);
+ this->ReadTest(configElem);
}
}
}
-const std::vector&
-TestRegistry::GetTestsForId(const std::string& pluginid)
+const QList&
+TestRegistry::GetTestsForId(const QString& pluginid)
{
return mapIdToTests[pluginid];
}
-void TestRegistry::ReadTest(IConfigurationElement::Pointer testElem)
+void TestRegistry::ReadTest(const IConfigurationElement::Pointer& testElem)
{
ITestDescriptor::Pointer descriptor(new TestDescriptor(testElem));
- poco_assert(descriptor->GetId() != "");
+ Q_ASSERT(!descriptor->GetId().isEmpty());
mapIdToTests[descriptor->GetContributor()].push_back(descriptor);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.h b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.h
index 4ec11668f2..93e01f6908 100644
--- a/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.test/src/internal/berryTestRegistry.h
@@ -1,57 +1,52 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYTESTREGISTRY_H_
#define BERRYTESTREGISTRY_H_
-#include
+#include
#include "berryITestDescriptor.h"
-#include
-#include
-
namespace berry {
class TestRegistry
{
public:
- static const std::string TAG_TEST; // = "test"
- static const std::string ATT_ID; // = "id"
- static const std::string ATT_CLASS; // = "class"
- static const std::string ATT_DESCRIPTION; // = "description"
- static const std::string ATT_UITEST; // = "uitest"
-
- static const std::string TEST_MANIFEST; // = "CppUnitTest"
+ static const QString TAG_TEST; // = "test"
+ static const QString ATT_ID; // = "id"
+ static const QString ATT_CLASS; // = "class"
+ static const QString ATT_DESCRIPTION; // = "description"
+ static const QString ATT_UITEST; // = "uitest"
TestRegistry();
- const std::vector& GetTestsForId(const std::string& pluginid);
+ const QList& GetTestsForId(const QString& pluginid);
protected:
- void ReadTest(IConfigurationElement::Pointer testElem);
+ void ReadTest(const IConfigurationElement::Pointer& testElem);
private:
- Poco::HashMap > mapIdToTests;
+ QHash > mapIdToTests;
};
}
#endif /* BERRYTESTREGISTRY_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake
index fde8abe0d2..77c88fca81 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake
@@ -1,468 +1,470 @@
set(SRC_CPP_FILES
berryAbstractSourceProvider.cpp
berryAbstractUICTKPlugin.cpp
berryConstants.cpp
berryDisplay.cpp
berryEditorPart.cpp
berryFileEditorInput.cpp
berryGeometry.cpp
berryIActionBars.h
berryIContextService.cpp
berryIContributionRoot.h
berryIDropTargetListener.cpp
berryIEditorDescriptor.cpp
berryIEditorInput.cpp
berryIEditorMatchingStrategy.cpp
berryIEditorPart.cpp
berryIEditorReference.cpp
berryIEditorRegistry.cpp
berryIEditorSite.cpp
berryIFileEditorMapping.cpp
berryIFolderLayout.cpp
berryImageDescriptor.cpp
berryIMemento.cpp
berryINullSelectionListener.cpp
berryIPageLayout.cpp
berryIPartListener.cpp
berryIPageService.cpp
berryIPartService.cpp
berryIPathEditorInput.cpp
berryIPerspectiveDescriptor.cpp
berryIPerspectiveFactory.cpp
berryIPerspectiveListener.cpp
berryIPerspectiveRegistry.cpp
berryIPlaceholderFolderLayout.cpp
berryIPluginContribution.h
berryIPostSelectionProvider.cpp
berryIPreferencePage.cpp
berryIPropertyChangeListener.cpp
berryIQtPreferencePage.cpp
berryIQtStyleManager.cpp
berryIReusableEditor.cpp
berryISaveablePart.cpp
berryISaveablesLifecycleListener.cpp
berryISaveablesSource.cpp
berryISelection.cpp
berryISelectionChangedListener.cpp
berryISelectionListener.cpp
berryISelectionProvider.cpp
berryISelectionService.cpp
berryIShellListener.cpp
berryIShellProvider.cpp
berryIShowInSource.h
berryIShowInTarget.h
berryISizeProvider.cpp
berryISourceProvider.cpp
berryISourceProviderListener.cpp
berryISources.cpp
berryIStickyViewDescriptor.cpp
berryIStructuredSelection.cpp
berryIViewCategory.cpp
berryIViewDescriptor.cpp
berryIViewLayout.cpp
berryIViewPart.cpp
berryIViewReference.cpp
berryIViewRegistry.cpp
berryIViewSite.cpp
berryIWorkbenchCommandConstants.cpp
berryIWindowListener.cpp
berryIWorkbench.cpp
berryIWorkbenchListener.cpp
berryIWorkbenchPage.cpp
berryIWorkbenchPart.cpp
berryIWorkbenchPartConstants.cpp
berryIWorkbenchPartDescriptor.cpp
berryIWorkbenchPartReference.cpp
berryIWorkbenchPartSite.cpp
berryIWorkbenchSite.cpp
berryIWorkbenchWindow.cpp
berryMenuUtil.cpp
berryPlatformUI.cpp
berryPoint.cpp
berryPropertyChangeEvent.cpp
berryQModelIndexObject.cpp
berryQtEditorPart.cpp
berryQtItemSelection.cpp
berryQtIntroPart.cpp
berryQtPreferences.cpp
berryQtSelectionProvider.cpp
berryQtViewPart.cpp
berryRectangle.cpp
berrySameShellProvider.cpp
berrySaveable.cpp
berrySaveablesLifecycleEvent.cpp
berrySelectionChangedEvent.cpp
berryShell.cpp
berryShellEvent.cpp
berryShowInContext.cpp
berryUIException.cpp
berryViewPart.cpp
berryWindow.cpp
berryWorkbenchActionConstants.cpp
berryWorkbenchPart.cpp
berryWorkbenchPreferenceConstants.cpp
berryXMLMemento.cpp
#actions
actions/berryAbstractContributionFactory.cpp
actions/berryAbstractGroupMarker.cpp
#actions/berryAction.cpp
#actions/berryActionContributionItem.cpp
actions/berryCommandContributionItem.h
actions/berryCommandContributionItem.cpp
actions/berryContributionItem.cpp
actions/berryContributionItemFactory.cpp
actions/berryContributionManager.cpp
actions/berryIContributionItem.h
actions/berryIContributionManager.h
actions/berryIContributionManagerOverrides.cpp
actions/berryIMenuManager.h
- #actions/berryManuBarManager.cpp
+ #actions/berryMenuBarManager.cpp
actions/berryMenuManager.cpp
actions/berrySeparator.cpp
actions/berrySubContributionItem.cpp
#application
application/berryActionBarAdvisor.cpp
application/berryIActionBarConfigurer.cpp
application/berryIWorkbenchConfigurer.cpp
application/berryIWorkbenchWindowConfigurer.cpp
application/berryWorkbenchAdvisor.cpp
application/berryWorkbenchWindowAdvisor.cpp
#commands
commands/berryICommandImageService.cpp
commands/berryICommandService.cpp
commands/berryIElementReference.h
commands/berryIElementUpdater.h
commands/berryIMenuService.h
commands/berryUIElement.cpp
#dialogs
dialogs/berryIDialog.cpp
dialogs/berryIShowViewDialog.cpp
dialogs/berryMessageDialog.cpp
#guitk
guitk/berryGuiTkControlEvent.cpp
guitk/berryGuiTkEvent.cpp
guitk/berryGuiTkIControlListener.cpp
guitk/berryGuiTkIMenuListener.cpp
guitk/berryGuiTkISelectionListener.cpp
guitk/berryGuiTkSelectionEvent.cpp
#handlers
handlers/berryHandlerUtil.cpp
handlers/berryIHandlerActivation.cpp
handlers/berryIHandlerService.cpp
handlers/berryRadioState.cpp
handlers/berryRegistryToggleState.cpp
handlers/berryShowViewHandler.cpp
handlers/berryToggleState.cpp
#intro
intro/berryIIntroManager.cpp
intro/berryIIntroPart.cpp
intro/berryIIntroSite.cpp
intro/berryIntroPart.cpp
#tweaklets
tweaklets/berryDnDTweaklet.cpp
tweaklets/berryGuiWidgetsTweaklet.cpp
tweaklets/berryImageTweaklet.cpp
tweaklets/berryMessageDialogTweaklet.cpp
tweaklets/berryITracker.cpp
tweaklets/berryWorkbenchPageTweaklet.cpp
tweaklets/berryWorkbenchTweaklet.cpp
#presentations
presentations/berryIPresentablePart.cpp
presentations/berryIPresentationFactory.cpp
presentations/berryIPresentationSerializer.cpp
presentations/berryIStackPresentationSite.cpp
presentations/berryStackDropResult.cpp
presentations/berryStackPresentation.cpp
#services
services/berryIDisposable.cpp
services/berryIEvaluationReference.h
services/berryIEvaluationService.cpp
services/berryINestable.cpp
services/berryIServiceFactory.cpp
services/berryIServiceLocator.cpp
services/berryIServiceScopes.cpp
services/berryIServiceWithSources.cpp
services/berryISourceProviderService.cpp
#testing
testing/berryTestableObject.cpp
#util
util/berryISafeRunnableRunner.cpp
util/berrySafeRunnable.cpp
# application
application/berryQtWorkbenchAdvisor.cpp
)
set(INTERNAL_CPP_FILES
defaultpresentation/berryEmptyTabFolder.cpp
defaultpresentation/berryEmptyTabItem.cpp
defaultpresentation/berryNativeTabFolder.cpp
defaultpresentation/berryNativeTabItem.cpp
defaultpresentation/berryQCTabBar.cpp
defaultpresentation/berryQtWorkbenchPresentationFactory.cpp
util/berryAbstractTabFolder.cpp
util/berryAbstractTabItem.cpp
util/berryIPresentablePartList.cpp
util/berryLeftToRightTabOrder.cpp
util/berryPartInfo.cpp
util/berryPresentablePartFolder.cpp
util/berryReplaceDragHandler.cpp
util/berryTabbedStackPresentation.cpp
util/berryTabDragHandler.cpp
util/berryTabFolderEvent.cpp
util/berryTabOrder.cpp
#intro
intro/berryEditorIntroAdapterPart.cpp
intro/berryIIntroDescriptor.cpp
intro/berryIIntroRegistry.cpp
intro/berryIntroConstants.cpp
intro/berryIntroDescriptor.cpp
intro/berryIntroPartAdapterSite.cpp
intro/berryIntroRegistry.cpp
intro/berryViewIntroAdapterPart.cpp
intro/berryWorkbenchIntroManager.cpp
berryAbstractMenuAdditionCacheEntry.cpp
berryAbstractPartSelectionTracker.cpp
berryAbstractSelectionService.cpp
berryActivePartExpression.cpp
berryAlwaysEnabledExpression.cpp
berryAndExpression.cpp
berryBundleUtility.cpp
berryCommandContributionItemParameter.cpp
berryCommandParameter.cpp
berryCommandPersistence.cpp
berryCommandService.cpp
berryCommandServiceFactory.cpp
berryCommandStateProxy.cpp
berryCompositeExpression.cpp
berryContainerPlaceholder.cpp
berryContributionRoot.cpp
berryDetachedPlaceHolder.cpp
berryDefaultSaveable.cpp
berryDefaultStackPresentationSite.cpp
berryDetachedWindow.cpp
berryDragUtil.cpp
berryEditorAreaHelper.cpp
berryEditorDescriptor.cpp
berryEditorManager.cpp
berryEditorReference.cpp
berryEditorRegistry.cpp
berryEditorRegistryReader.cpp
berryEditorSashContainer.cpp
berryEditorSite.cpp
berryElementReference.cpp
berryErrorViewPart.cpp
berryEvaluationAuthority.cpp
berryEvaluationReference.cpp
berryEvaluationResultCache.cpp
berryEvaluationService.cpp
berryExpressionAuthority.cpp
berryFileEditorMapping.cpp
berryFolderLayout.cpp
berryHandlerActivation.cpp
berryHandlerAuthority.cpp
berryHandlerPersistence.cpp
berryHandlerProxy.cpp
berryHandlerService.cpp
berryHandlerServiceFactory.cpp
berryIDragOverListener.cpp
berryIDropTarget.cpp
berryIEvaluationResultCache.cpp
berryILayoutContainer.cpp
berryInternalMenuService.h
berryIServiceLocatorCreator.cpp
berryIStickyViewManager.cpp
berryIWorkbenchLocationService.cpp
berryLayoutHelper.cpp
berryLayoutPart.cpp
berryLayoutPartSash.cpp
berryLayoutTree.cpp
berryLayoutTreeNode.cpp
berryMenuServiceFactory.cpp
berryMMMenuListener.cpp
berryNestableHandlerService.cpp
berryNullEditorInput.cpp
berryPageLayout.cpp
berryPagePartSelectionTracker.cpp
berryPageSelectionService.cpp
berryParameterValueConverterProxy.cpp
berryPartList.cpp
berryPartPane.cpp
berryPartPlaceholder.cpp
berryPartSashContainer.cpp
berryPartService.cpp
berryPartSite.cpp
berryPartStack.cpp
berryPartTester.cpp
berryPersistentState.cpp
berryPerspective.cpp
berryPerspectiveDescriptor.cpp
berryPerspectiveExtensionReader.cpp
berryPerspectiveHelper.cpp
berryPerspectiveRegistry.cpp
berryPerspectiveRegistryReader.cpp
berryPlaceholderFolderLayout.cpp
berryPreferenceConstants.cpp
berryPresentablePart.cpp
berryPresentationFactoryUtil.cpp
berryPresentationSerializer.cpp
berryQtControlWidget.cpp
berryQtDnDControlWidget.cpp
berryQtDisplay.cpp
berryQtDnDTweaklet.cpp
berryQtFileImageDescriptor.cpp
berryQtGlobalEventFilter.cpp
berryQtIconImageDescriptor.cpp
berryQtImageTweaklet.cpp
berryQtMainWindowControl.cpp
berryQtMessageDialogTweaklet.cpp
berryQtMissingImageDescriptor.cpp
berryQtOpenPerspectiveAction.cpp
berryQtPerspectiveSwitcher.cpp
berryQtSafeApplication.cpp
berryQtSash.cpp
berryQtShell.cpp
berryQtShowViewAction.cpp
berryQtShowViewDialog.cpp
berryQtStyleManager.cpp
berryQtStylePreferencePage.cpp
berryQtTracker.cpp
berryQtWidgetController.cpp
berryQtWidgetsTweaklet.cpp
berryQtWidgetsTweakletImpl.cpp
berryQtWorkbenchPageTweaklet.cpp
berryQtWorkbenchTweaklet.cpp
berryRegistryPersistence.cpp
berryRegistryReader.cpp
berrySaveablesList.cpp
berryShowViewMenu.cpp
berryServiceLocator.cpp
berryServiceLocatorCreator.cpp
berryShellPool.cpp
berrySlaveCommandService.cpp
berrySlaveHandlerService.cpp
berrySlaveMenuService.cpp
berrySourceProviderService.cpp
berrySourcePriorityNameMapping.cpp
berryStatusUtil.cpp
berryStickyViewDescriptor.cpp
berryStickyViewManager.cpp
berryTweaklets.cpp
berryUtil.cpp
berryViewDescriptor.cpp
berryViewFactory.cpp
berryViewLayout.cpp
berryViewReference.cpp
berryViewRegistry.cpp
berryViewRegistryReader.cpp
berryViewSashContainer.cpp
berryViewSite.cpp
berryWorkbenchPage.cpp
berryWindowManager.cpp
berryWindowPartSelectionTracker.cpp
berryWindowSelectionService.cpp
berryWorkbench.cpp
berryWorkbenchConfigurer.cpp
berryWorkbenchConstants.cpp
berryWorkbenchLocationService.cpp
berryWorkbenchMenuService.cpp
berryWorkbenchPagePartList.cpp
berryWorkbenchPartReference.cpp
berryWorkbenchPlugin.cpp
berryWorkbenchRegistryConstants.cpp
berryWorkbenchServiceRegistry.cpp
berryWorkbenchSourceProvider.cpp
berryWorkbenchTestable.cpp
berryWorkbenchWindow.cpp
berryWorkbenchWindowConfigurer.cpp
berryWorkbenchWindowExpression.cpp
berryWWinActionBars.cpp
berryWWinPartService.cpp
)
set(MOC_H_FILES
+ src/berryAbstractUICTKPlugin.h
src/berryEditorPart.h
src/berryQtSelectionProvider.h
src/berryViewPart.h
src/berryWorkbenchPart.h
src/actions/berryCommandContributionItem.h
src/intro/berryIntroPart.h
src/handlers/berryShowViewHandler.h
src/internal/berryCommandServiceFactory.h
src/internal/berryHandlerServiceFactory.h
src/internal/berryMenuServiceFactory.h
src/internal/berryMMMenuListener.h
- src/internal/berryWorkbenchSourceProvider.h
src/internal/berryQtDisplay.h
src/internal/berryQtDnDTweaklet.h
src/internal/berryQtGlobalEventFilter.h
src/internal/berryQtImageTweaklet.h
src/internal/berryQtMainWindowControl.h
src/internal/berryQtMessageDialogTweaklet.h
src/internal/berryQtOpenPerspectiveAction.h
src/internal/berryQtPerspectiveSwitcher.h
src/internal/berryQtSash.h
src/internal/berryQtShowViewAction.h
src/internal/berryQtStyleManager.h
src/internal/berryQtStylePreferencePage.h
src/internal/berryQtTracker.h
src/internal/berryQtWidgetsTweaklet.h
src/internal/berryQtWidgetsTweakletImpl.h
src/internal/berryQtWorkbenchTweaklet.h
src/internal/berryQtWorkbenchPageTweaklet.h
+ src/internal/berryWorkbenchPlugin.h
+ src/internal/berryWorkbenchSourceProvider.h
src/internal/defaultpresentation/berryNativeTabFolder.h
src/internal/defaultpresentation/berryNativeTabItem.h
src/internal/defaultpresentation/berryQCTabBar.h
src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h
src/internal/intro/berryEditorIntroAdapterPart.h
)
set(UI_FILES
src/internal/berryQtShowViewDialog.ui
src/internal/berryQtStylePreferencePage.ui
src/internal/berryQtStatusPart.ui
)
set(QRC_FILES
resources/org_blueberry_ui_qt.qrc
)
set(CACHED_RESOURCE_FILES
plugin.xml
)
set(CPP_FILES )
foreach(file ${SRC_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/${file})
endforeach(file ${SRC_CPP_FILES})
foreach(file ${INTERNAL_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/internal/${file})
endforeach(file ${INTERNAL_CPP_FILES})
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.h
index ab4218e075..60ea407751 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.h
@@ -1,331 +1,332 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYABSTRACTUICTKPLUGIN_H_
#define BERRYABSTRACTUICTKPLUGIN_H_
#include
#include
namespace berry {
template class SmartPointer;
struct IPreferences;
struct IPreferencesService;
struct IWorkbench;
struct ImageDescriptor;
/**
* \ingroup org_blueberry_ui_qt
*
* Abstract base class for plug-ins that integrate with the BlueBerry platform UI.
*
* Subclasses obtain the following capabilities:
*
*
* Preferences
*
* - The platform core runtime contains general support for plug-in
* preferences (
org.blueberry.core.runtime.Preferences
).
* This class provides appropriate conversion to the older JFace preference
* API (org.blueberry.jface.preference.IPreferenceStore
).
* - The method
getPreferenceStore
returns the JFace preference
* store (cf. Plugin.getPluginPreferences
which returns
* a core runtime preferences object.
* - Subclasses may reimplement
initializeDefaultPreferences
* to set up any default values for preferences using JFace API. In this
* case, initializeDefaultPluginPreferences
should not be
* overridden.
* - Subclasses may reimplement
*
initializeDefaultPluginPreferences
to set up any default
* values for preferences using core runtime API. In this
* case, initializeDefaultPreferences
should not be
* overridden.
* - Preferences are also saved automatically on plug-in shutdown.
* However, saving preferences immediately after changing them is
* strongly recommended, since that ensures that preference settings
* are not lost even in the event of a platform crash.
*
* Dialogs
*
* - The dialog store is read the first time
getDialogSettings
* is called.
* - The dialog store allows the plug-in to "record" important choices made
* by the user in a wizard or dialog, so that the next time the
* wizard/dialog is used the widgets can be defaulted to better values. A
* wizard could also use it to record the last 5 values a user entered into
* an editable combo - to show "recent values".
* - The dialog store is found in the file whose name is given by the
* constant
FN_DIALOG_STORE
. A dialog store file is first
* looked for in the plug-in's read/write state area; if not found there,
* the plug-in's install directory is checked.
* This allows a plug-in to ship with a read-only copy of a dialog store
* file containing initial values for certain settings.
* - Plug-in code can call
saveDialogSettings
to cause settings to
* be saved in the plug-in's read/write state area. A plug-in may opt to do
* this each time a wizard or dialog is closed to ensure the latest
* information is always safe on disk.
* - Dialog settings are also saved automatically on plug-in shutdown.
*
* Images
*
* - A typical UI plug-in will have some images that are used very frequently
* and so need to be cached and shared. The plug-in's image registry
* provides a central place for a plug-in to store its common images.
* Images managed by the registry are created lazily as needed, and will be
* automatically disposed of when the plug-in shuts down. Note that the
* number of registry images should be kept to a minimum since many OSs
* have severe limits on the number of images that can be in memory at once.
*
*
* For easy access to your plug-in object, use the singleton pattern. Declare a
* static variable in your plug-in class for the singleton. Store the first
* (and only) instance of the plug-in class in the singleton when it is created.
* Then access the singleton when needed through a static getDefault
* method.
*
*
* See the description on {@link Plugin}.
*
*/
class BERRY_UI_QT AbstractUICTKPlugin : public Plugin
{
+ Q_OBJECT
private:
/**
* The name of the dialog settings file (value
* "dialog_settings.xml"
).
*/
static const QString FN_DIALOG_SETTINGS;
/**
* Storage for dialog and wizard data; null
if not yet
* initialized.
*/
//DialogSettings dialogSettings = null;
/**
* Storage for preferences.
*/
mutable IPreferencesService* preferencesService;
/**
* The registry for all graphic images; null
if not yet
* initialized.
*/
//ImageRegistry imageRegistry = null;
/**
* The bundle listener used for kicking off refreshPluginActions().
*/
//BundleListener bundleListener;
public:
/**
* Creates an abstract UI plug-in runtime object.
*
* Plug-in runtime classes are ctkPluginActivator
s and so must
* have an default constructor. This method is called by the runtime when
* the associated bundle is being activated.
*/
AbstractUICTKPlugin();
/**
* Returns the dialog settings for this UI plug-in.
* The dialog settings is used to hold persistent state data for the various
* wizards and dialogs of this plug-in in the context of a workbench.
*
* If an error occurs reading the dialog store, an empty one is quietly created
* and returned.
*
*
* Subclasses may override this method but are not expected to.
*
*
* @return the dialog settings
*/
// IDialogSettings getDialogSettings();
/**
* Returns the image registry for this UI plug-in.
*
* The image registry contains the images used by this plug-in that are very
* frequently used and so need to be globally shared within the plug-in. Since
* many OSs have a severe limit on the number of images that can be in memory at
* any given time, a plug-in should only keep a small number of images in their
* registry.
*
* Subclasses should reimplement initializeImageRegistry
if they have
* custom graphic images to load.
*
*
* Subclasses may override this method but are not expected to.
*
*
* @return the image registry
*/
// ImageRegistry getImageRegistry();
/**
* Returns the preferences service for this UI plug-in.
* This preferences service is used to hold persistent settings for this plug-in in
* the context of a workbench. Some of these settings will be user controlled,
* whereas others may be internal setting that are never exposed to the user.
*
* If an error occurs reading the preferences service, an empty preference service is
* quietly created, initialized with defaults, and returned.
*
*
* @return the preferences service
*/
IPreferencesService* GetPreferencesService() const;
SmartPointer GetPreferences() const;
/**
* Returns the Platform UI workbench.
*
* This method exists as a convenience for plugin implementors. The
* workbench can also be accessed by invoking PlatformUI.getWorkbench()
.
*
* @return IWorkbench the workbench for this plug-in
*/
IWorkbench* GetWorkbench();
protected:
/**
* Returns a new image registry for this plugin-in. The registry will be
* used to manage images which are frequently used by the plugin-in.
*
* The default implementation of this method creates an empty registry.
* Subclasses may override this method if needed.
*
*
* @return ImageRegistry the resulting registry.
* @see #getImageRegistry
*/
// ImageRegistry createImageRegistry();
/**
* Initializes an image registry with images which are frequently used by the
* plugin.
*
* The image registry contains the images used by this plug-in that are very
* frequently used and so need to be globally shared within the plug-in. Since
* many OSs have a severe limit on the number of images that can be in memory
* at any given time, each plug-in should only keep a small number of images in
* its registry.
*
* Implementors should create a JFace image descriptor for each frequently used
* image. The descriptors describe how to create/find the image should it be needed.
* The image described by the descriptor is not actually allocated until someone
* retrieves it.
*
* Subclasses may override this method to fill the image registry.
*
* @param reg the registry to initalize
*
* @see #getImageRegistry
*/
// void initializeImageRegistry(ImageRegistry reg);
/**
* Loads the dialog settings for this plug-in.
* The default implementation first looks for a standard named file in the
* plug-in's read/write state area; if no such file exists, the plug-in's
* install directory is checked to see if one was installed with some default
* settings; if no file is found in either place, a new empty dialog settings
* is created. If a problem occurs, an empty settings is silently used.
*
* This framework method may be overridden, although this is typically
* unnecessary.
*
*/
// void loadDialogSettings();
/**
* Refreshes the actions for the plugin.
* This method is called from startup
.
*
* This framework method may be overridden, although this is typically
* unnecessary.
*
*/
// void refreshPluginActions();
/**
* Saves this plug-in's dialog settings.
* Any problems which arise are silently ignored.
*/
// void saveDialogSettings();
public:
/**
* The AbstractUIPlugin
implementation of this Plugin
* method refreshes the plug-in actions. Subclasses may extend this method,
* but must send super first.
*/
void start(ctkPluginContext* context);
/**
* The AbstractUIPlugin
implementation of this Plugin
* method saves this plug-in's preference and dialog stores and shuts down
* its image registry (if they are in use). Subclasses may extend this
* method, but must send super last. A try-finally statement should
* be used where necessary to ensure that super.shutdown()
is
* always done.
*/
void stop(ctkPluginContext* context);
/**
* Creates and returns a new image descriptor for an image file located
* within the specified plug-in.
*
* This is a convenience method that simply locates the image file in
* within the plug-in (no image registries are involved). The path is
* relative to the root of the plug-in, and takes into account files
* coming from plug-in fragments. The path may include $arg$ elements.
* However, the path must not have a leading "." or path separator.
* Clients should use a path like "icons/mysample.gif" rather than
* "./icons/mysample.gif" or "/icons/mysample.gif".
*
*
* @param pluginId the id of the plug-in containing the image file;
* null
is returned if the plug-in does not exist
* @param imageFilePath the relative path of the image file, relative to the
* root of the plug-in; the path must be legal
* @return an image descriptor, or null
if no image
* could be found
* @since 3.0
*/
static SmartPointer ImageDescriptorFromPlugin(
const QString& pluginId, const QString& imageFilePath);
};
} // namespace berry
#endif /*BERRYABSTRACTUICTKPLUGIN_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveDescriptor.h
index ff6426a977..2ec27bd1df 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveDescriptor.h
@@ -1,124 +1,124 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIPERSPECTIVEDESCRIPTOR_H_
#define BERRYIPERSPECTIVEDESCRIPTOR_H_
#include
#include
#include
#include "berryImageDescriptor.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_qt
*
* A perspective descriptor describes a perspective in an
* IPerspectiveRegistry
.
*
* A perspective is a template for view visibility, layout, and action visibility
* within a workbench page. There are two types of perspective: a predefined
* perspective and a custom perspective.
*
* - A predefined perspective is defined by an extension to the workbench's
* perspective extension point (
"org.blueberry.ui.perspectives"
).
* The extension defines a id, label, and IPerspectiveFactory
.
* A perspective factory is used to define the initial layout for a page.
*
* - A custom perspective is defined by the user. In this case a predefined
* perspective is modified to suit a particular task and saved as a new
* perspective. The attributes for the perspective are stored in a separate file
* in the workbench's metadata directory.
*
*
*
*
* Within a page the user can open any of the perspectives known
* to the workbench's perspective registry, typically by selecting one from the
* workbench's Open Perspective
menu. When selected, the views
* and actions within the active page rearrange to reflect the perspective.
*
*
* This interface is not intended to be implemented by clients.
*
* @see IPerspectiveRegistry
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI_QT IPerspectiveDescriptor : public Object
{
berryObjectMacro(berry::IPerspectiveDescriptor)
virtual ~IPerspectiveDescriptor();
/**
* Returns the description of this perspective.
* This is the value of its "description"
attribute.
*
* @return the description
* @since 3.0
*/
virtual QString GetDescription() const = 0;
/**
* Returns this perspective's id. For perspectives declared via an extension,
* this is the value of its "id"
attribute.
*
* @return the perspective id
*/
virtual QString GetId() const = 0;
/**
* Returns the descriptor of the image to show for this perspective.
* If the extension for this perspective specifies an image, the descriptor
* for it is returned. Otherwise a default image is returned.
*
* @return the descriptor of the image to show for this perspective
*/
virtual ImageDescriptor::Pointer GetImageDescriptor() const = 0;
/**
* Returns this perspective's label. For perspectives declared via an extension,
* this is the value of its "label"
attribute.
*
* @return the label
*/
virtual QString GetLabel() const = 0;
/**
* Returns true
if this perspective is predefined by an
* extension.
*
* @return boolean whether this perspective is predefined by an extension
*/
virtual bool IsPredefined() const = 0;
/**
* Return the category path of this descriptor
*
* @return the category path of this descriptor
*/
- virtual std::vector GetCategoryPath() = 0;
+ virtual QStringList GetCategoryPath() const = 0;
- virtual std::vector< std::string> GetKeywordReferences() const = 0;
+ virtual QStringList GetKeywordReferences() const = 0;
};
}
#endif /*BERRYIPERSPECTIVEDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveRegistry.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveRegistry.cpp
index 9f821a8320..5f48d52ed6 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveRegistry.cpp
@@ -1,25 +1,26 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryIPerspectiveRegistry.h"
namespace berry
{
IPerspectiveRegistry::~IPerspectiveRegistry()
{
}
+
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveRegistry.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveRegistry.h
index 83a25476b1..ad1f0adb69 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveRegistry.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIPerspectiveRegistry.h
@@ -1,143 +1,138 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIPERSPECTIVEREGISTRY_H_
#define BERRYIPERSPECTIVEREGISTRY_H_
#include "berryIPerspectiveDescriptor.h"
#include
namespace berry {
/**
* \ingroup org_blueberry_ui
*
* The workbench's global registry of perspectives.
*
* This registry contains a descriptor for each perspectives in the workbench.
* It is initially populated with stock perspectives from the workbench's
* perspective extension point ("org.blueberry.ui.perspectives"
) and
* with custom perspectives defined by the user.
*
* This interface is not intended to be implemented by clients.
*
* @see IWorkbench#getPerspectiveRegistry
* @noimplement This interface is not intended to be implemented by clients.
*/
struct BERRY_UI_QT IPerspectiveRegistry {
- virtual ~IPerspectiveRegistry();
-
- /**
- * Create a new perspective.
- *
- * @param label
- * the name of the new descriptor
- * @param originalDescriptor
- * the descriptor on which to base the new descriptor
- * @return a new perspective descriptor or null
if the
- * creation failed.
- */
- virtual IPerspectiveDescriptor::Pointer CreatePerspective(const std::string& label,
- IPerspectiveDescriptor::Pointer originalDescriptor) = 0;
-
- /**
- * Clones an existing perspective.
- *
- * @param id the id for the cloned perspective, which must not already be used by
- * any registered perspective
- * @param label the label assigned to the cloned perspective
- * @param desc the perspective to clone
- * @return the cloned perspective descriptor
- * @throws IllegalArgumentException if there is already a perspective with the given id
- *
- * @since 3.0
- */
- virtual IPerspectiveDescriptor::Pointer ClonePerspective(const QString& id, const QString& label,
- IPerspectiveDescriptor::Pointer desc) = 0;
+ virtual ~IPerspectiveRegistry();
+
+ /**
+ * Create a new perspective.
+ *
+ * @param label
+ * the name of the new descriptor
+ * @param originalDescriptor
+ * the descriptor on which to base the new descriptor
+ * @return a new perspective descriptor or null
if the
+ * creation failed.
+ */
+ virtual IPerspectiveDescriptor::Pointer CreatePerspective(const QString& label,
+ IPerspectiveDescriptor::Pointer originalDescriptor) = 0;
+
+ /**
+ * Clones an existing perspective.
+ *
+ * @param id the id for the cloned perspective, which must not already be used by
+ * any registered perspective
+ * @param label the label assigned to the cloned perspective
+ * @param desc the perspective to clone
+ * @return the cloned perspective descriptor
+ * @throws IllegalArgumentException if there is already a perspective with the given id
+ */
+ virtual IPerspectiveDescriptor::Pointer ClonePerspective(const QString& id, const QString& label,
+ IPerspectiveDescriptor::Pointer desc) = 0;
/**
* Deletes a perspective. Has no effect if the perspective is defined in an
* extension.
*
* @param persp the perspective to delete
- * @since 3.2
*/
virtual void DeletePerspective(IPerspectiveDescriptor::Pointer persp) = 0;
- /**
- * Finds and returns the registered perspective with the given perspective id.
- *
- * @param perspectiveId the perspective id
- * @return the perspective, or null
if none
- * @see IPerspectiveDescriptor#getId
- */
- virtual IPerspectiveDescriptor::Pointer FindPerspectiveWithId(const QString& perspectiveId) = 0;
-
- /**
- * Finds and returns the registered perspective with the given label.
- *
- * @param label the label
- * @return the perspective, or null
if none
- * @see IPerspectiveDescriptor#getLabel
- */
- virtual IPerspectiveDescriptor::Pointer FindPerspectiveWithLabel(const QString& label) = 0;
-
- /**
- * Returns the id of the default perspective for the workbench. This identifies one
- * perspective extension within the workbench's perspective registry.
- *
- * Returns null
if there is no default perspective.
- *
- *
- * @return the default perspective id, or null
- */
- virtual QString GetDefaultPerspective() = 0;
-
- /**
- * Returns a list of the perspectives known to the workbench.
- *
- * @return a list of perspectives
- */
- virtual QList GetPerspectives() = 0;
-
- /**
- * Sets the default perspective for the workbench to the given perspective id.
- * If non-null
, the id must correspond to a perspective extension
- * within the workbench's perspective registry.
- *
- * A null
id indicates no default perspective.
- *
- *
- * @param id a perspective id, or null
- */
- virtual void SetDefaultPerspective(const QString& id) = 0;
-
- /**
- * Reverts a perspective back to its original definition
- * as specified in the plug-in manifest.
- *
- * @param perspToRevert the perspective to revert
- *
- * @since 3.0
- */
- virtual void RevertPerspective(IPerspectiveDescriptor::Pointer perspToRevert) = 0;
+ /**
+ * Finds and returns the registered perspective with the given perspective id.
+ *
+ * @param perspectiveId the perspective id
+ * @return the perspective, or null
if none
+ * @see IPerspectiveDescriptor#getId
+ */
+ virtual IPerspectiveDescriptor::Pointer FindPerspectiveWithId(const QString& perspectiveId) = 0;
+
+ /**
+ * Finds and returns the registered perspective with the given label.
+ *
+ * @param label the label
+ * @return the perspective, or null
if none
+ * @see IPerspectiveDescriptor#getLabel
+ */
+ virtual IPerspectiveDescriptor::Pointer FindPerspectiveWithLabel(const QString& label) = 0;
+
+ /**
+ * Returns the id of the default perspective for the workbench. This identifies one
+ * perspective extension within the workbench's perspective registry.
+ *
+ * Returns null
if there is no default perspective.
+ *
+ *
+ * @return the default perspective id, or null
+ */
+ virtual QString GetDefaultPerspective() = 0;
+
+ /**
+ * Returns a list of the perspectives known to the workbench.
+ *
+ * @return a list of perspectives
+ */
+ virtual QList GetPerspectives() = 0;
+
+ /**
+ * Sets the default perspective for the workbench to the given perspective id.
+ * If non-null
, the id must correspond to a perspective extension
+ * within the workbench's perspective registry.
+ *
+ * A null
id indicates no default perspective.
+ *
+ *
+ * @param id a perspective id, or null
+ */
+ virtual void SetDefaultPerspective(const QString& id) = 0;
+
+ /**
+ * Reverts a perspective back to its original definition
+ * as specified in the plug-in manifest.
+ *
+ * @param perspToRevert the perspective to revert
+ */
+ virtual void RevertPerspective(IPerspectiveDescriptor::Pointer perspToRevert) = 0;
};
}
#endif /*BERRYIPERSPECTIVEREGISTRY_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIViewDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIViewDescriptor.h
index 8d34d15f69..9a99615885 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIViewDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIViewDescriptor.h
@@ -1,109 +1,106 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIVIEWDESCRIPTOR_H_
#define BERRYIVIEWDESCRIPTOR_H_
#include
#include "berryIWorkbenchPartDescriptor.h"
#include "berryIViewPart.h"
#include
#include
#include "berryImageDescriptor.h"
-#include
-#include
-
namespace berry
{
/**
* \ingroup org_blueberry_ui_qt
*
* This is a view descriptor. It provides a "description" of a given
* given view so that the view can later be constructed.
*
* The view registry provides facilities to map from an extension
* to a IViewDescriptor.
*
*
* This interface is not intended to be implemented by clients.
*
*
* @see org.blueberry.ui.IViewRegistry
*/
struct BERRY_UI_QT IViewDescriptor : public IWorkbenchPartDescriptor, public IAdaptable
{
berryObjectMacro(berry::IViewDescriptor)
~IViewDescriptor();
/**
* Creates an instance of the view defined in the descriptor.
*
* @return the view part
* @throws CoreException thrown if there is a problem creating the part
*/
virtual IViewPart::Pointer CreateView() = 0;
- virtual std::vector< std::string> GetKeywordReferences() const = 0;
+ virtual QStringList GetKeywordReferences() const = 0;
/**
* Returns an array of strings that represent
* view's category path. This array will be used
* for hierarchical presentation of the
* view in places like submenus.
* @return array of category tokens or null if not specified.
*/
- virtual const QList& GetCategoryPath() const = 0;
+ virtual QStringList GetCategoryPath() const = 0;
/**
* Returns the description of this view.
*
* @return the description
*/
virtual QString GetDescription() const = 0;
/**
* Returns the descriptor for the icon to show for this view.
*/
virtual SmartPointer GetImageDescriptor() const = 0;
/**
* Returns whether this view allows multiple instances.
*
* @return whether this view allows multiple instances
*/
virtual bool GetAllowMultiple() const = 0;
/**
* Returns whether this view can be restored upon workbench restart.
*
* @return whether whether this view can be restored upon workbench restart
*/
virtual bool IsRestorable() const = 0;
virtual bool operator==(const Object*) const = 0;
};
}
#endif /*BERRYIVIEWDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPage.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPage.h
index 5a13e28c6e..21f7db8adf 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPage.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchPage.h
@@ -1,854 +1,854 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIWORKBENCHPAGE_H_
#define BERRYIWORKBENCHPAGE_H_
#include
#include "berryIEditorReference.h"
#include "berryIViewReference.h"
#include "berryIPerspectiveDescriptor.h"
#include "berryIEditorPart.h"
#include "berryIViewPart.h"
#include "berryIEditorInput.h"
#include "berryIPartService.h"
#include "berryISelectionService.h"
#include "berryIReusableEditor.h"
#include "berryIWorkbenchWindow.h"
/**
* \ingroup org_blueberry_ui_qt
*
*/
namespace berry {
/**
* A workbench page consists of an arrangement of views and editors intended to
* be presented together to the user in a single workbench window.
*
* A page can contain 0 or more views and 0 or more editors. These views and
* editors are contained wholly within the page and are not shared with other
* pages. The layout and visible action set for the page is defined by a
* perspective.
*
* The number of views and editors within a page is restricted to simplify part
* management for the user. In particular:
*
* - Unless a view explicitly allows for multiple instances in its plugin
* declaration there will be only one instance in a given workbench page.
* - Only one editor can exist for each editor input within a page.
*
-
*
*
*
* This interface is not intended to be implemented by clients.
*
*
* @see IPerspectiveDescriptor
* @see IEditorPart
* @see IViewPart
*/
struct BERRY_UI_QT IWorkbenchPage : public IPartService, public ISelectionService, public Object
{
berryObjectMacro(berry::IWorkbenchPage)
~IWorkbenchPage();
/**
* An optional attribute within a workspace marker (IMarker
)
* which identifies the preferred editor type to be opened when
* openEditor
is called.
*
* @see #openEditor(IEditorInput, String)
* @see #openEditor(IEditorInput, String, boolean)
* @deprecated in 3.0 since the notion of markers this is not generally
* applicable. Use the IDE-specific constant
* IDE.EDITOR_ID_ATTR
.
*/
static const QString EDITOR_ID_ATTR; // = "org.blueberry.ui.editorID";
/**
* Change event id when the perspective is reset to its original state.
*
* @see IPerspectiveListener
*/
static const QString CHANGE_RESET; // = "reset";
/**
* Change event id when the perspective has completed a reset to its
* original state.
*
* @since 3.0
* @see IPerspectiveListener
*/
static const QString CHANGE_RESET_COMPLETE; // = "resetComplete";
/**
* Change event id when one or more views are shown in a perspective.
*
* @see IPerspectiveListener
*/
static const QString CHANGE_VIEW_SHOW; // = "viewShow";
/**
* Change event id when one or more views are hidden in a perspective.
*
* @see IPerspectiveListener
*/
static const QString CHANGE_VIEW_HIDE; // = "viewHide";
/**
* Change event id when one or more editors are opened in a perspective.
*
* @see IPerspectiveListener
*/
static const QString CHANGE_EDITOR_OPEN; // = "editorOpen";
/**
* Change event id when one or more editors are closed in a perspective.
*
* @see IPerspectiveListener
*/
static const QString CHANGE_EDITOR_CLOSE; // = "editorClose";
/**
* Change event id when the editor area is shown in a perspective.
*
* @see IPerspectiveListener
*/
static const QString CHANGE_EDITOR_AREA_SHOW; // = "editorAreaShow";
/**
* Change event id when the editor area is hidden in a perspective.
*
* @see IPerspectiveListener
*/
static const QString CHANGE_EDITOR_AREA_HIDE; // = "editorAreaHide";
/**
* Change event id when an action set is shown in a perspective.
*
* @see IPerspectiveListener
*/
static const QString CHANGE_ACTION_SET_SHOW; // = "actionSetShow";
/**
* Change event id when an action set is hidden in a perspective.
*
* @see IPerspectiveListener
*/
static const QString CHANGE_ACTION_SET_HIDE; // = "actionSetHide";
/**
* Show view mode that indicates the view should be made visible and
* activated. Use of this mode has the same effect as calling
* {@link #showView(String)}.
*/
static const int VIEW_ACTIVATE; // = 1;
/**
* Show view mode that indicates the view should be made visible. If the
* view is opened in the container that contains the active view then this
* has the same effect as VIEW_CREATE
.
*/
static const int VIEW_VISIBLE; // = 2;
/**
* Show view mode that indicates the view should be made created but not
* necessarily be made visible. It will only be made visible in the event
* that it is opened in its own container. In other words, only if it is not
* stacked with another view.
*/
static const int VIEW_CREATE; // = 3;
/**
* Editor opening match mode specifying that no matching against existing
* editors should be done.
*/
static const int MATCH_NONE; // = 0;
/**
* Editor opening match mode specifying that the editor input should be
* considered when matching against existing editors.
*/
static const int MATCH_INPUT; // = 1;
/**
* Editor opening match mode specifying that the editor id should be
* considered when matching against existing editors.
*/
static const int MATCH_ID; // = 2;
/**
* Activates the given part. The part will be brought to the front and given
* focus. The part must belong to this page.
*
* @param part
* the part to activate
*/
virtual void Activate(IWorkbenchPart::Pointer part) = 0;
/**
* Adds a property change listener.
*
* @param listener
* the property change listener to add
*/
//virtual void addPropertyChangeListener(IPropertyChangeListener listener);
/**
* Moves the given part forward in the Z order of this page so as to make it
* visible, without changing which part has focus. The part must belong to
* this page.
*
* @param part
* the part to bring forward
*/
virtual void BringToTop(IWorkbenchPart::Pointer part) = 0;
/**
* Closes this workbench page. If this page is the active one, this honor is
* passed along to one of the window's other pages if possible.
*
* If the page has an open editor with unsaved content, the user will be
* given the opportunity to save it.
*
*
* @return true
if the page was successfully closed, and
* false
if it is still open
*/
virtual bool Close() = 0;
/**
* Closes all of the editors belonging to this workbench page.
*
* If the page has open editors with unsaved content and save
* is true
, the user will be given the opportunity to save
* them.
*
*
* @param save
*
* @return true
if all editors were successfully closed, and
* false
if at least one is still open
*/
virtual bool CloseAllEditors(bool save) = 0;
/**
* Closes the given Array
of editor references. The editors
* must belong to this workbench page.
*
* If any of the editors have unsaved content and save
is
* true
, the user will be given the opportunity to save
* them.
*
*
* @param editorRefs
* the editors to close
* @param save
* true
to save the editor contents if required
* (recommended), and false
to discard any unsaved
* changes
* @return true
if the editors were successfully closed, and
* false
if the editors are still open
*/
virtual bool CloseEditors(const QList& editorRefs, bool save) = 0;
/**
* Closes the given editor. The editor must belong to this workbench page.
*
* If the editor has unsaved content and save
is
* true
, the user will be given the opportunity to save it.
*
*
* @param editor
* the editor to close
* @param save
* true
to save the editor contents if required
* (recommended), and false
to discard any unsaved
* changes
* @return true
if the editor was successfully closed, and
* false
if the editor is still open
*/
virtual bool CloseEditor(IEditorPart::Pointer editor, bool save) = 0;
/**
* Returns the view in this page with the specified id. There is at most one
* view in the page with the specified id.
*
* @param viewId
* the id of the view extension to use
* @return the view, or null
if none is found
*/
virtual IViewPart::Pointer FindView(const QString& viewId) = 0;
/**
* Returns the view reference with the specified id.
*
* @param viewId
* the id of the view extension to use
* @return the view reference, or null
if none is found
*/
virtual IViewReference::Pointer FindViewReference(const QString& viewId) = 0;
/**
* Returns the view reference with the specified id and secondary id.
*
* @param viewId
* the id of the view extension to use
* @param secondaryId
* the secondary id to use, or null
for no
* secondary id
* @return the view reference, or null
if none is found
*/
virtual IViewReference::Pointer FindViewReference(const QString& viewId, const QString& secondaryId) = 0;
/**
* Returns the active editor open in this page.
*
* This is the visible editor on the page, or, if there is more than one
* visible editor, this is the one most recently brought to top.
*
*
* @return the active editor, or null
if no editor is active
*/
virtual IEditorPart::Pointer GetActiveEditor() = 0;
/**
* Returns the editor with the specified input. Returns null if there is no
* opened editor with that input.
*
* @param input
* the editor input
* @return an editor with input equals to input
*/
virtual IEditorPart::Pointer FindEditor(IEditorInput::Pointer input) = 0;
/**
* Returns an array of editor references that match the given input and/or
* editor id, as specified by the given match flags. Returns an empty array
* if there are no matching editors, or if matchFlags is MATCH_NONE.
*
* @param input
* the editor input, or null
if MATCH_INPUT is not
* specified in matchFlags
* @param editorId
* the editor id, or null
if MATCH_ID is not
* specified in matchFlags
* @param matchFlags
* a bit mask consisting of zero or more of the MATCH_* constants
* OR-ed together
* @return the references for the matching editors
*
* @see #MATCH_NONE
* @see #MATCH_INPUT
* @see #MATCH_ID
*/
virtual QList FindEditors(IEditorInput::Pointer input, const QString& editorId,
int matchFlags) = 0;
/**
* Returns a list of the editors open in this page.
*
* Note that each page has its own editors; editors are never shared between
* pages.
*
*
* @return a list of open editors
*
* @deprecated use #getEditorReferences() instead
*/
virtual QList GetEditors() = 0;
/**
* Returns an array of references to open editors in this page.
*
* Note that each page has its own editors; editors are never shared between
* pages.
*
*
* @return a list of open editors
*/
virtual QList GetEditorReferences() = 0;
/**
* Returns a list of dirty editors in this page.
*
* @return a list of dirty editors
*/
virtual QList GetDirtyEditors() = 0;
/**
* Returns the input for this page.
*
* @return the input for this page, or null
if none
*/
virtual IAdaptable* GetInput() = 0;
/**
* Returns the page label. This will be a unique identifier within the
* containing workbench window.
*
* @return the page label
*/
virtual QString GetLabel() = 0;
/**
* Returns the current perspective descriptor for this page, or
* null
if there is no current perspective.
*
* @return the current perspective descriptor or null
* @see #setPerspective
* @see #savePerspective
*/
virtual IPerspectiveDescriptor::Pointer GetPerspective() = 0;
/**
* Returns a list of the reference to views visible on this page.
*
* Note that each page has its own views; views are never shared between
* pages.
*
*
* @return a list of references to visible views
*/
virtual QList GetViewReferences() = 0;
/**
* Returns a list of the views visible on this page.
*
* Note that each page has its own views; views are never shared between
* pages.
*
*
* @return a list of visible views
*
* @deprecated use #getViewReferences() instead.
*/
virtual QList GetViews() = 0;
/**
* Returns the workbench window of this page.
*
* @return the workbench window
*/
virtual IWorkbenchWindow::Pointer GetWorkbenchWindow() = 0;
/**
* Hides the given view. The view must belong to this page.
*
* @param view
* the view to hide
*/
virtual void HideView(IViewPart::Pointer view) = 0;
/**
* Hides the given view that belongs to the reference, if any.
*
* @param view
* the references whos view is to be hidden
*/
virtual void HideView(IViewReference::Pointer view) = 0;
/**
* Returns true if perspective with given id contains view with given id
*/
- virtual bool HasView(const std::string& perspectiveId, const std::string& viewId) = 0;
+ virtual bool HasView(const QString& perspectiveId, const QString& viewId) = 0;
/**
* Returns whether the specified part is visible.
*
* @param part
* the part to test
* @return boolean true
if part is visible
*/
virtual bool IsPartVisible(IWorkbenchPart::Pointer part) = 0;
/**
* Removes the perspective specified by desc.
*
* @param desc
* the perspective that will be removed
*/
virtual void RemovePerspective(IPerspectiveDescriptor::Pointer desc) = 0;
/**
* Reuses the specified editor by setting its new input.
*
* @param editor
* the editor to be reused
* @param input
* the new input for the reusable editor
*/
virtual void ReuseEditor(IReusableEditor::Pointer editor, IEditorInput::Pointer input) = 0;
/**
* Opens an editor on the given input.
*
* If this page already has an editor open on the target input that editor
* is activated; otherwise, a new editor is opened. Two editor inputs,
* input1 and input2, are considered the same if
*
*
* input1.equals(input2) == true
*
.
*
*
* The editor type is determined by mapping editorId
to an
* editor extension registered with the workbench. An editor id is passed
* rather than an editor object to prevent the accidental creation of more
* than one editor for the same input. It also guarantees a consistent
* lifecycle for editors, regardless of whether they are created by the user
* or restored from saved data.
*
*
* @param input
* the editor input
* @param editorId
* the id of the editor extension to use
* @return an open and active editor, or null
if an external
* editor was opened
* @exception PartInitException
* if the editor could not be created or initialized
*/
virtual IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input, const QString& editorId) = 0;
/**
* Opens an editor on the given input.
*
* If this page already has an editor open on the target input that editor
* is brought to the front; otherwise, a new editor is opened. Two editor
* inputs are considered the same if they equal. See
* Object.equals(Object)
* and IEditorInput
. If activate == true
the editor
* will be activated.
*
* The editor type is determined by mapping editorId
to an editor
* extension registered with the workbench. An editor id is passed rather than
* an editor object to prevent the accidental creation of more than one editor
* for the same input. It also guarantees a consistent lifecycle for editors,
* regardless of whether they are created by the user or restored from saved
* data.
*
*
* @param input the editor input
* @param editorId the id of the editor extension to use
* @param activate if true
the editor will be activated
* @return an open editor, or null
if an external editor was opened
* @exception PartInitException if the editor could not be created or initialized
*/
virtual IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input, const QString& editorId,
bool activate) = 0;
/**
* Opens an editor on the given input.
*
* If this page already has an editor open that matches the given input
* and/or editor id (as specified by the matchFlags argument), that editor
* is brought to the front; otherwise, a new editor is opened. Two editor
* inputs are considered the same if they equal. See
* Object.equals(Object)
* and IEditorInput
. If activate == true
the editor
* will be activated.
*
* The editor type is determined by mapping editorId
to an editor
* extension registered with the workbench. An editor id is passed rather than
* an editor object to prevent the accidental creation of more than one editor
* for the same input. It also guarantees a consistent lifecycle for editors,
* regardless of whether they are created by the user or restored from saved
* data.
*
*
* @param input the editor input
* @param editorId the id of the editor extension to use
* @param activate if true
the editor will be activated
* @param matchFlags a bit mask consisting of zero or more of the MATCH_* constants OR-ed together
* @return an open editor, or null
if an external editor was opened
* @exception PartInitException if the editor could not be created or initialized
*
* @see #MATCH_NONE
* @see #MATCH_INPUT
* @see #MATCH_ID
*/
virtual IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input,
const QString& editorId, bool activate, int matchFlags) = 0;
/**
* Removes the property change listener.
*
* @param listener
* the property change listener to remove
*/
//virtual void removePropertyChangeListener(IPropertyChangeListener listener);
/**
* Changes the visible views, their layout, and the visible action sets
* within the page to match the current perspective descriptor. This is a
* rearrangement of components and not a replacement. The contents of the
* current perspective descriptor are unaffected.
*
* For more information on perspective change see
* setPerspective()
.
*
*/
virtual void ResetPerspective() = 0;
/**
* Saves the contents of all dirty editors belonging to this workbench page.
* If there are no dirty editors this method returns without effect.
*
* If confirm
is true
the user is prompted to
* confirm the command.
*
*
* Note that as of 3.2, this method also saves views that implement
* ISaveablePart and are dirty.
*
*
* @param confirm true
to ask the user before saving unsaved
* changes (recommended), and false
to save
* unsaved changes without asking
* @return true
if the command succeeded, and
* false
if the operation was canceled by the user or
* an error occurred while saving
*/
virtual bool SaveAllEditors(bool confirm) = 0;
/**
* Saves the contents of the given editor if dirty. If not, this method
* returns without effect.
*
* If confirm
is true
the user is prompted to
* confirm the command. Otherwise, the save happens without prompt.
*
*
* The editor must belong to this workbench page.
*
*
* @param editor
* the editor to close
* @param confirm
* true
to ask the user before saving unsaved
* changes (recommended), and false
to save
* unsaved changes without asking
* @return true
if the command succeeded, and
* false
if the editor was not saved
*/
virtual bool SaveEditor(IEditorPart::Pointer editor, bool confirm) = 0;
/**
* Saves the visible views, their layout, and the visible action sets for
* this page to the current perspective descriptor. The contents of the
* current perspective descriptor are overwritten.
*/
virtual void SavePerspective() = 0;
/**
* Saves the visible views, their layout, and the visible action sets for
* this page to the given perspective descriptor. The contents of the given
* perspective descriptor are overwritten and it is made the current one for
* this page.
*
* @param perspective
* the perspective descriptor to save to
*/
virtual void SavePerspectiveAs(IPerspectiveDescriptor::Pointer perspective) = 0;
/**
* Changes the visible views, their layout, and the visible action sets
* within the page to match the given perspective descriptor. This is a
* rearrangement of components and not a replacement. The contents of the
* old perspective descriptor are unaffected.
*
* When a perspective change occurs the old perspective is deactivated
* (hidden) and cached for future reference. Then the new perspective is
* activated (shown). The views within the page are shared by all existing
* perspectives to make it easy for the user to switch between one
* perspective and another quickly without loss of context.
*
*
* During activation the action sets are modified. If an action set is
* specified in the new perspective which is not visible in the old one it
* will be created. If an old action set is not specified in the new
* perspective it will be disposed.
*
*
* The visible views and their layout within the page also change. If a view
* is specified in the new perspective which is not visible in the old one a
* new instance of the view will be created. If an old view is not specified
* in the new perspective it will be hidden. This view may reappear if the
* user selects it from the View menu or if they switch to a perspective
* (which may be the old one) where the view is visible.
*
*
* The open editors are not modified by this method.
*
*
* @param perspective
* the perspective descriptor
*/
virtual void SetPerspective(IPerspectiveDescriptor::Pointer perspective) = 0;
/**
* Shows the view identified by the given view id in this page and gives it
* focus. If there is a view identified by the given view id (and with no
* secondary id) already open in this page, it is given focus.
*
* @param viewId
* the id of the view extension to use
* @return the shown view
* @exception PartInitException
* if the view could not be initialized
*/
virtual IViewPart::Pointer ShowView(const QString& viewId) = 0;
/**
* Shows a view in this page with the given id and secondary id. The
* behaviour of this method varies based on the supplied mode. If
* VIEW_ACTIVATE
is supplied, the view is focus. If
* VIEW_VISIBLE
is supplied, then it is made visible but not
* given focus. Finally, if VIEW_CREATE
is supplied the view
* is created and will only be made visible if it is not created in a folder
* that already contains visible views.
*
* This allows multiple instances of a particular view to be created. They
* are disambiguated using the secondary id. If a secondary id is given, the
* view must allow multiple instances by having specified
* allowMultiple="true" in its extension.
*
*
* @param viewId
* the id of the view extension to use
* @param secondaryId
* the secondary id to use, or null
for no
* secondary id
* @param mode
* the activation mode. Must be {@link #VIEW_ACTIVATE},
* {@link #VIEW_VISIBLE} or {@link #VIEW_CREATE}
* @return a view
* @exception PartInitException
* if the view could not be initialized
* @exception IllegalArgumentException
* if the supplied mode is not valid
*/
virtual IViewPart::Pointer ShowView(const QString& viewId, const QString& secondaryId, int mode) = 0;
/**
* Returns true
if the editor is pinned and should not be
* reused.
*
* @param editor
* the editor to test
* @return boolean whether the editor is pinned
*/
virtual bool IsEditorPinned(IEditorPart::Pointer editor) = 0;
/**
* Returns the perspective shortcuts associated with the current
* perspective. Returns an empty array if there is no current perspective.
*
* @see IPageLayout#addPerspectiveShortcut(String)
* @return an array of perspective identifiers
*/
virtual QList GetPerspectiveShortcuts() = 0;
/**
* Returns the show view shortcuts associated with the current perspective.
* Returns an empty array if there is no current perspective.
*
* @see IPageLayout#addShowViewShortcut(String)
* @return an array of view identifiers
*/
virtual QList GetShowViewShortcuts() = 0;
/**
* Returns the descriptors for the perspectives that are open in this page,
* in the order in which they were opened.
*
* @return the open perspective descriptors, in order of opening
*/
virtual QList GetOpenPerspectives() = 0;
/**
* Returns the descriptors for the perspectives that are open in this page,
* in the order in which they were activated (oldest first).
*
* @return the open perspective descriptors, in order of activation
*/
virtual QList GetSortedPerspectives() = 0;
/**
* Closes current perspective. If last perspective, then entire page
* is closed.
*
* @param saveParts
* whether the page's parts should be saved if closed
* @param closePage
* whether the page itself should be closed if last perspective
*/
virtual void CloseCurrentPerspective(bool saveParts, bool closePage) = 0;
/**
* Closes the specified perspective in this page. If the last perspective in
* this page is closed, then all editors are closed. Views that are not
* shown in other perspectives are closed as well. If saveParts
* is true
, the user will be prompted to save any unsaved
* changes for parts that are being closed. The page itself is closed if
* closePage
is true
.
*
* @param desc
* the descriptor of the perspective to be closed
* @param saveParts
* whether the page's parts should be saved if closed
* @param closePage
* whether the page itself should be closed if last perspective
*/
virtual void ClosePerspective(IPerspectiveDescriptor::Pointer desc,
bool saveParts, bool closePage) = 0;
/**
* Closes all perspectives in this page. All editors are closed, prompting
* to save any unsaved changes if saveEditors
is
* true
. The page itself is closed if closePage
* is true
.
*
* @param saveEditors
* whether the page's editors should be saved
* @param closePage
* whether the page itself should be closed
*/
virtual void CloseAllPerspectives(bool saveEditors, bool closePage) = 0;
/**
* Find the part reference for the given part. A convenience method to
* quickly go from part to part reference.
*
* @param part
* The part to search for. It can be null
.
* @return The reference for the given part, or null
if no
* reference can be found.
*/
virtual IWorkbenchPartReference::Pointer GetReference(IWorkbenchPart::Pointer part) = 0;
};
} // namespace berry
#endif /*BERRYIWORKBENCHPAGE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchWindow.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchWindow.h
index 16e689863e..5c21b6ff59 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchWindow.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryIWorkbenchWindow.h
@@ -1,213 +1,213 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIWORKBENCHWINDOW_H_
#define BERRYIWORKBENCHWINDOW_H_
#include
#include
#include
#include "berryIPageService.h"
#include "berryShell.h"
#include "services/berryIServiceLocator.h"
namespace berry {
struct IPartService;
struct ISelectionService;
struct IWorkbenchPage;
struct IWorkbench;
/**
* \ingroup org_blueberry_ui_qt
*
* A workbench window is a top level window in a workbench. Visually, a
* workbench window has a menubar, a toolbar, a status bar, and a main area for
* displaying a single page consisting of a collection of views and editors.
*
* Each workbench window has a collection of 0 or more pages; the active page is
* the one that is being presented to the end user; at most one page is active
* in a window at a time.
*
*
* The workbench window supports a few {@link IServiceLocator services} by
* default. If these services are used to allocate resources, it is important to
* remember to clean up those resources after you are done with them. Otherwise,
* the resources will exist until the workbench window is closed. The supported
* services are:
*
*
* - {@link ICommandService}
* - {@link IContextService}
* - {@link IHandlerService}
* - {@link IBindingService}. Resources allocated through this service will
* not be cleaned up until the workbench shuts down.
*
*
* This interface is not intended to be implemented by clients.
*
*
* @see IWorkbenchPage
* @noimplement This interface is not intended to be implemented by clients.
*
*/
struct BERRY_UI_QT IWorkbenchWindow : public IPageService, public IServiceLocator, public virtual Object
{
berryObjectMacro(berry::IWorkbenchWindow)
/**
* Closes this workbench window.
*
* If the window has an open editor with unsaved content, the user will be
* given the opportunity to save it.
*
*
* @return true
if the window was successfully closed, and
* false
if it is still open
*/
virtual bool Close() = 0;
- virtual SmartPointer GetPage(int i) = 0;
+ virtual SmartPointer GetPage(int i) const = 0;
/**
* Returns the currently active page for this workbench window.
*
* @return the active page, or null
if none
*/
virtual SmartPointer GetActivePage() const = 0;
/**
* Sets or clears the currently active page for this workbench window.
*
* @param page
* the new active page
*/
virtual void SetActivePage(SmartPointer page) = 0;
/**
* Returns the part service which tracks part activation within this
* workbench window.
*
* @return the part service
*/
virtual IPartService* GetPartService() = 0;
/**
* Returns the selection service which tracks selection within this
* workbench window.
*
* @return the selection service
*/
virtual ISelectionService* GetSelectionService() = 0;
/**
* Returns this workbench window's shell.
*
* @return the shell containing this window's controls or null
* if the shell has not been created yet or if the window has been closed
*/
virtual Shell::Pointer GetShell() const = 0;
/**
* Returns the workbench for this window.
*
* @return the workbench
*/
virtual IWorkbench* GetWorkbench() = 0;
/**
* Returns whether the specified menu is an application menu as opposed to
* a part menu. Application menus contain items which affect the workbench
* or window. Part menus contain items which affect the active part (view
* or editor).
*
* This is typically used during "in place" editing. Application menus
* should be preserved during menu merging. All other menus may be removed
* from the window.
*
*
* @param menuId
* the menu id
* @return true
if the specified menu is an application
* menu, and false
if it is not
*/
//virtual bool IsApplicationMenu(const QString& menuId) = 0;
/**
* Creates and opens a new workbench page. The perspective of the new page
* is defined by the specified perspective ID. The new page become active.
*
* Note: Since release 2.0, a window is limited to contain at most
* one page. If a page exist in the window when this method is used, then
* another window is created for the new page. Callers are strongly
* recommended to use the IWorkbench.showPerspective
APIs to
* programmatically show a perspective.
*
*
* @param perspectiveId
* the perspective id for the window's initial page
* @param input
* the page input, or null
if there is no current
* input. This is used to seed the input for the new page's
* views.
* @return the new workbench page
* @exception WorkbenchException
* if a page could not be opened
*
* @see IWorkbench#showPerspective(String, IWorkbenchWindow, IAdaptable)
*/
virtual SmartPointer OpenPage(const QString& perspectiveId, IAdaptable* input) = 0;
/**
* Creates and opens a new workbench page. The default perspective is used
* as a template for creating the page. The page becomes active.
*
* Note: Since release 2.0, a window is limited to contain at most
* one page. If a page exist in the window when this method is used, then
* another window is created for the new page. Callers are strongly
* recommended to use the IWorkbench.showPerspective
APIs to
* programmatically show a perspective.
*
*
* @param input
* the page input, or null
if there is no current
* input. This is used to seed the input for the new page's
* views.
* @return the new workbench window
* @exception WorkbenchException
* if a page could not be opened
*
* @see IWorkbench#showPerspective(String, IWorkbenchWindow, IAdaptable)
*/
virtual SmartPointer OpenPage(IAdaptable* input) = 0;
- virtual void SetPerspectiveExcludeList(std::vector v) = 0;
- virtual std::vector GetPerspectiveExcludeList() = 0;
+ virtual void SetPerspectiveExcludeList(const QStringList& v) = 0;
+ virtual QStringList GetPerspectiveExcludeList() const = 0;
- virtual void SetViewExcludeList(std::vector v) = 0;
- virtual std::vector GetViewExcludeList() = 0;
+ virtual void SetViewExcludeList(const QStringList& v) = 0;
+ virtual QStringList GetViewExcludeList() const = 0;
virtual ~IWorkbenchWindow();
};
}
#endif /*BERRYIWORKBENCHWINDOW_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspective.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspective.cpp
index f83af8992f..7ec7694dd2 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspective.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspective.cpp
@@ -1,1811 +1,1811 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryPerspective.h"
#include "berryPerspectiveHelper.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchConstants.h"
#include "berryPerspectiveExtensionReader.h"
#include "berryEditorSashContainer.h"
#include "berryPartSite.h"
#include "berryViewSite.h"
#include "berryEditorAreaHelper.h"
#include "intro/berryIntroConstants.h"
#include "dialogs/berryMessageDialog.h"
#include "berryWorkbenchWindow.h"
#include "berryStatusUtil.h"
#include "presentations/berryIStackPresentationSite.h"
namespace berry
{
const QString Perspective::VERSION_STRING = "0.016";
Perspective::Perspective(PerspectiveDescriptor::Pointer desc,
WorkbenchPage::Pointer page)
: descriptor(desc)
{
this->Init(page);
if (desc.IsNotNull())
{
this->CreatePresentation(desc);
}
}
Perspective::Perspective(WorkbenchPage::Pointer page)
{
this->Init(page);
}
void Perspective::Init(WorkbenchPage::Pointer page)
{
editorHidden = false;
editorAreaState = IStackPresentationSite::STATE_RESTORED;
fixed = false;
presentation = 0;
shouldHideEditorsOnActivate = false;
this->page = page.GetPointer();
this->editorArea = page->GetEditorPresentation()->GetLayoutPart();
this->viewFactory = page->GetViewFactory();
}
bool Perspective::BringToTop(IViewReference::Pointer ref)
{
return presentation->BringPartToTop(this->GetPane(ref));
}
bool Perspective::ContainsView(IViewPart::Pointer view)
{
IViewSite::Pointer site = view->GetViewSite();
IViewReference::Pointer ref = this->FindView(site->GetId(), site->GetSecondaryId());
if (ref.IsNull())
{
return false;
}
return (view.Cast() == ref->GetPart(false));
}
-bool Perspective::ContainsView(const std::string& viewId)
+bool Perspective::ContainsView(const QString& viewId) const
{
return mapIDtoViewLayoutRec.contains(viewId);
}
void Perspective::CreatePresentation(PerspectiveDescriptor::Pointer persp)
{
if (persp->HasCustomDefinition())
{
this->LoadCustomPersp(persp);
}
else
{
this->LoadPredefinedPersp(persp);
}
}
Perspective::~Perspective()
{
// Get rid of presentation.
if (presentation == 0)
{
DisposeViewRefs();
return;
}
presentation->Deactivate();
// Release each view.
QList refs(this->GetViewReferences());
for (QList::size_type i = 0, length = refs.size(); i < length; i++)
{
this->GetViewFactory()->ReleaseView(refs[i]);
}
mapIDtoViewLayoutRec.clear();
delete presentation;
}
void Perspective::DisposeViewRefs()
{
if (!memento)
{
return;
}
QList views(memento->GetChildren(WorkbenchConstants::TAG_VIEW));
for (int x = 0; x < views.size(); x++)
{
// Get the view details.
IMemento::Pointer childMem = views[x];
QString id; childMem->GetString(WorkbenchConstants::TAG_ID, id);
// skip creation of the intro reference - it's handled elsewhere.
if (id == IntroConstants::INTRO_VIEW_ID)
{
continue;
}
QString secondaryId = ViewFactory::ExtractSecondaryId(id);
if (!secondaryId.isEmpty())
{
id = ViewFactory::ExtractPrimaryId(id);
}
QString removed;
childMem->GetString(WorkbenchConstants::TAG_REMOVED, removed);
if (removed != "true")
{
IViewReference::Pointer ref = viewFactory->GetView(id, secondaryId);
if (ref)
{
viewFactory->ReleaseView(ref);
}
}
}
}
IViewReference::Pointer Perspective::FindView(const QString& viewId)
{
return this->FindView(viewId, "");
}
IViewReference::Pointer Perspective::FindView(const QString& id, const QString& secondaryId)
{
QList refs(this->GetViewReferences());
for (int i = 0; i < refs.size(); i++)
{
IViewReference::Pointer ref = refs[i];
if (id == ref->GetId()
&& (secondaryId == ref->GetSecondaryId()))
{
return ref;
}
}
return IViewReference::Pointer(0);
}
void* Perspective::GetClientComposite()
{
return page->GetClientComposite();
}
IPerspectiveDescriptor::Pointer Perspective::GetDesc()
{
return descriptor;
}
PartPane::Pointer Perspective::GetPane(IViewReference::Pointer ref)
{
return ref.Cast()->GetPane();
}
QList Perspective::GetPerspectiveShortcuts()
{
return perspectiveShortcuts;
}
PerspectiveHelper* Perspective::GetPresentation() const
{
return presentation;
}
QList Perspective::GetShowViewShortcuts()
{
return showViewShortcuts;
}
ViewFactory* Perspective::GetViewFactory()
{
return viewFactory;
}
QList Perspective::GetViewReferences()
{
// Get normal views.
if (presentation == 0)
{
return QList();
}
QList panes;
presentation->CollectViewPanes(panes);
QList result;
// List fastViews = (fastViewManager != 0) ?
// fastViewManager.getFastViews(0)
// : new ArrayList();
// IViewReference[] resultArray = new IViewReference[panes.size()
// + fastViews.size()];
//
// // Copy fast views.
// int nView = 0;
// for (int i = 0; i < fastViews.size(); i++)
// {
// resultArray[nView] = (IViewReference) fastViews.get(i);
// ++nView;
// }
// Copy normal views.
for (QList::iterator iter = panes.begin();
iter != panes.end(); ++iter)
{
PartPane::Pointer pane = *iter;
result.push_back(pane->GetPartReference().Cast());
}
return result;
}
void Perspective::HideEditorArea()
{
if (!this->IsEditorAreaVisible())
{
return;
}
// Show the editor in the appropriate location
if (this->UseNewMinMax(Perspective::Pointer(this)))
{
// If it's the currently maximized part we have to restore first
// if (this->GetPresentation().getMaximizedStack().Cast() != 0)
// {
// getPresentation().getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED);
// }
bool isMinimized = editorAreaState == IStackPresentationSite::STATE_MINIMIZED;
if (!isMinimized)
this->HideEditorAreaLocal();
//else
// this->SetEditorAreaTrimVisibility(false);
}
else
{
this->HideEditorAreaLocal();
}
editorHidden = true;
}
void Perspective::HideEditorAreaLocal()
{
if (editorHolder != 0)
{
return;
}
// Replace the editor area with a placeholder so we
// know where to put it back on show editor area request.
editorHolder = new PartPlaceholder(editorArea->GetID());
presentation->GetLayout()->Replace(editorArea, editorHolder);
}
bool Perspective::HideView(IViewReference::Pointer ref)
{
// If the view is locked just return.
PartPane::Pointer pane = this->GetPane(ref);
presentation->RemovePart(pane);
// Dispose view if ref count == 0.
this->GetViewFactory()->ReleaseView(ref);
return true;
}
bool Perspective::IsEditorAreaVisible()
{
return !editorHidden;
}
ViewLayoutRec::Pointer Perspective::GetViewLayoutRec(IViewReference::Pointer ref, bool create)
{
ViewLayoutRec::Pointer result = this->GetViewLayoutRec(ViewFactory::GetKey(ref), create);
if (result.IsNull() && create==false)
{
result = this->GetViewLayoutRec(ref->GetId(), false);
}
return result;
}
ViewLayoutRec::Pointer Perspective::GetViewLayoutRec(const QString& viewId, bool create)
{
ViewLayoutRec::Pointer rec = mapIDtoViewLayoutRec[viewId];
if (rec.IsNull() && create)
{
rec = new ViewLayoutRec();
mapIDtoViewLayoutRec[viewId] = rec;
}
return rec;
}
bool Perspective::IsFixedLayout()
{
//@issue is there a difference between a fixed
//layout and a fixed perspective?? If not the API
//may need some polish, WorkbenchPage, PageLayout
//and Perspective all have isFixed methods.
//PageLayout and Perspective have their own fixed
//attribute, we are assuming they are always in sync.
//WorkbenchPage delegates to the perspective.
return fixed;
}
bool Perspective::IsStandaloneView(IViewReference::Pointer ref)
{
ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(ref, false);
return rec.IsNotNull() && rec->isStandalone;
}
bool Perspective::GetShowTitleView(IViewReference::Pointer ref)
{
ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(ref, false);
return rec.IsNotNull() && rec->showTitle;
}
void Perspective::LoadCustomPersp(PerspectiveDescriptor::Pointer persp)
{
//get the layout from the registry
PerspectiveRegistry* perspRegistry = dynamic_cast(WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry());
try
{
IMemento::Pointer memento = perspRegistry->GetCustomPersp(persp->GetId());
// Restore the layout state.
// MultiStatus status = new MultiStatus(
// PlatformUI.PLUGIN_ID,
// IStatus.OK,
// NLS.bind(WorkbenchMessages.Perspective_unableToRestorePerspective, persp.getLabel()),
// 0);
// status.merge(restoreState(memento));
// status.merge(restoreState());
bool okay = true;
okay &= this->RestoreState(memento);
okay &= this->RestoreState();
if (!okay)
{
this->UnableToOpenPerspective(persp, "Unable to open perspective: " + persp->GetLabel());
}
}
//catch (IOException e)
//{
// unableToOpenPerspective(persp, 0);
//}
catch (const WorkbenchException& e)
{
this->UnableToOpenPerspective(persp, e.what());
}
}
void Perspective::UnableToOpenPerspective(PerspectiveDescriptor::Pointer persp,
const QString& status)
{
PerspectiveRegistry* perspRegistry = dynamic_cast(WorkbenchPlugin
::GetDefault()->GetPerspectiveRegistry());
perspRegistry->DeletePerspective(persp);
// If this is a predefined perspective, we will not be able to delete
// the perspective (we wouldn't want to). But make sure to delete the
// customized portion.
persp->DeleteCustomDefinition();
QString title = "Restoring problems";
QString msg = "Unable to read workbench state.";
if (status == "")
{
MessageDialog::OpenError(Shell::Pointer(0), title, msg);
}
else
{
//TODO error dialog
//ErrorDialog.openError((Shell) 0, title, msg, status);
MessageDialog::OpenError(Shell::Pointer(0), title, msg + "\n" + status);
}
}
void Perspective::LoadPredefinedPersp(PerspectiveDescriptor::Pointer persp)
{
// Create layout engine.
IPerspectiveFactory::Pointer factory;
try
{
factory = persp->CreateFactory();
}
catch (CoreException& /*e*/)
{
throw WorkbenchException("Unable to load perspective: " + persp->GetId());
}
/*
* IPerspectiveFactory#createFactory() can return 0
*/
if (factory == 0)
{
throw WorkbenchException("Unable to load perspective: " + persp->GetId());
}
// Create layout factory.
ViewSashContainer::Pointer container(new ViewSashContainer(page, this->GetClientComposite()));
layout = new PageLayout(container, this->GetViewFactory(),
editorArea, descriptor);
layout->SetFixed(descriptor->GetFixed());
// // add the placeholders for the sticky folders and their contents
IPlaceholderFolderLayout::Pointer stickyFolderRight, stickyFolderLeft, stickyFolderTop, stickyFolderBottom;
QList descs(WorkbenchPlugin::GetDefault()
->GetViewRegistry()->GetStickyViews());
for (int i = 0; i < descs.size(); i++)
{
IStickyViewDescriptor::Pointer stickyViewDescriptor = descs[i];
QString id = stickyViewDescriptor->GetId();
int location = stickyViewDescriptor->GetLocation();
if (location == IPageLayout::RIGHT)
{
if (stickyFolderRight == 0)
{
stickyFolderRight = layout
->CreatePlaceholderFolder(
StickyViewDescriptor::STICKY_FOLDER_RIGHT,
IPageLayout::RIGHT, .75f,
IPageLayout::ID_EDITOR_AREA);
}
stickyFolderRight->AddPlaceholder(id);
}
else if (location == IPageLayout::LEFT)
{
if (stickyFolderLeft == 0)
{
stickyFolderLeft = layout->CreatePlaceholderFolder(
StickyViewDescriptor::STICKY_FOLDER_LEFT,
IPageLayout::LEFT, .25f, IPageLayout::ID_EDITOR_AREA);
}
stickyFolderLeft->AddPlaceholder(id);
}
else if (location == IPageLayout::TOP)
{
if (stickyFolderTop == 0)
{
stickyFolderTop = layout->CreatePlaceholderFolder(
StickyViewDescriptor::STICKY_FOLDER_TOP,
IPageLayout::TOP, .25f, IPageLayout::ID_EDITOR_AREA);
}
stickyFolderTop->AddPlaceholder(id);
}
else if (location == IPageLayout::BOTTOM)
{
if (stickyFolderBottom == 0)
{
stickyFolderBottom = layout->CreatePlaceholderFolder(
StickyViewDescriptor::STICKY_FOLDER_BOTTOM,
IPageLayout::BOTTOM, .75f,
IPageLayout::ID_EDITOR_AREA);
}
stickyFolderBottom->AddPlaceholder(id);
}
//should never be 0 as we've just added the view above
IViewLayout::Pointer viewLayout = layout->GetViewLayout(id);
viewLayout->SetCloseable(stickyViewDescriptor->IsCloseable());
viewLayout->SetMoveable(stickyViewDescriptor->IsMoveable());
}
// Run layout engine.
factory->CreateInitialLayout(layout);
PerspectiveExtensionReader extender;
extender.ExtendLayout(descriptor->GetId(), layout);
// Retrieve view layout info stored in the page layout.
QHash layoutInfo = layout->GetIDtoViewLayoutRecMap();
mapIDtoViewLayoutRec.unite(layoutInfo);
//TODO Perspective action sets
// Create action sets.
//List temp = new ArrayList();
//this->CreateInitialActionSets(temp, layout.getActionSets());
// IContextService service = 0;
// if (page != 0)
// {
// service = (IContextService) page.getWorkbenchWindow().getService(
// IContextService.class);
// }
// try
// {
// if (service!=0)
// {
// service.activateContext(ContextAuthority.DEFER_EVENTS);
// }
// for (Iterator iter = temp.iterator(); iter.hasNext();)
// {
// IActionSetDescriptor descriptor = (IActionSetDescriptor) iter
// .next();
// addAlwaysOn(descriptor);
// }
// }finally
// {
// if (service!=0)
// {
// service.activateContext(ContextAuthority.SEND_EVENTS);
// }
// }
// newWizardShortcuts = layout.getNewWizardShortcuts();
showViewShortcuts = layout->GetShowViewShortcuts();
// perspectiveShortcuts = layout.getPerspectiveShortcuts();
// showInPartIds = layout.getShowInPartIds();
//
// // Retrieve fast views
// if (fastViewManager != 0)
// {
// ArrayList fastViews = layout.getFastViews();
// for (Iterator fvIter = fastViews.iterator(); fvIter.hasNext();)
// {
// IViewReference ref = (IViewReference) fvIter.next();
// fastViewManager.addViewReference(FastViewBar.FASTVIEWBAR_ID, -1, ref,
// !fvIter.hasNext());
// }
// }
// Is the layout fixed
fixed = layout->IsFixed();
showViewShortcuts = layout->GetShowViewShortcuts();
// Create presentation.
presentation = new PerspectiveHelper(page, container, this);
// Hide editor area if requested by factory
if (!layout->IsEditorAreaVisible())
{
this->HideEditorArea();
}
}
void Perspective::OnActivate()
{
// Update editor area state.
if (editorArea->GetControl() != 0)
{
bool visible = this->IsEditorAreaVisible();
bool inTrim = editorAreaState == IStackPresentationSite::STATE_MINIMIZED;
editorArea->SetVisible(visible && !inTrim);
}
// // Update fast views.
// // Make sure the control for the fastviews are created so they can
// // be activated.
// if (fastViewManager != 0)
// {
// List fastViews = fastViewManager.getFastViews(0);
// for (int i = 0; i < fastViews.size(); i++)
// {
// ViewPane pane = getPane((IViewReference) fastViews.get(i));
// if (pane != 0)
// {
// Control ctrl = pane.getControl();
// if (ctrl == 0)
// {
// pane.createControl(getClientComposite());
// ctrl = pane.getControl();
// }
// ctrl.setEnabled(false); // Remove focus support.
// }
// }
// }
// // Set the visibility of all fast view pins
// setAllPinsVisible(true);
// Trim Stack Support
bool useNewMinMax = Perspective::UseNewMinMax(Perspective::Pointer(this));
bool hideEditorArea = shouldHideEditorsOnActivate || (editorHidden && editorHolder == 0);
// We have to set the editor area's stack state -before-
// activating the presentation since it's used there to determine
// size of the resulting stack
if (useNewMinMax && !hideEditorArea)
{
this->RefreshEditorAreaVisibility();
}
// Show the layout
presentation->Activate(this->GetClientComposite());
// if (useNewMinMax)
// {
// fastViewManager.activate();
//
// // Move any minimized extension stacks to the trim
// if (layout != 0)
// {
// // Turn aimations off
// IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
// bool useAnimations = preferenceStore
// .getbool(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS);
// preferenceStore.setValue(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, false);
//
// List minStacks = layout.getMinimizedStacks();
// for (Iterator msIter = minStacks.iterator(); msIter.hasNext();)
// {
// ViewStack vs = (ViewStack) msIter.next();
// vs.setMinimized(true);
// }
//
// // Restore the animation pref
// preferenceStore.setValue(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, useAnimations);
//
// // this is a one-off deal...set during the extension reading
// minStacks.clear();
// layout = 0;
// }
// }
// else
// {
// // Update the FVB only if not using the new min/max
//
// // WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow();
//// if (wbw != 0)
//// {
//// ITrimManager tbm = wbw.getTrimManager();
//// if (tbm != 0)
//// {
//// IWindowTrim fvb = tbm.getTrim(FastViewBar.FASTVIEWBAR_ID);
//// if (fvb instanceof FastViewBar)
//// {
//// ((FastViewBar)fvb).update(true);
//// }
//// }
//// }
// }
// // If we are -not- using the new min/max then ensure that there
// // are no stacks in the trim. This can happen when a user switches
// // back to the 3.0 presentation...
// if (!Perspective.useNewMinMax(this) && fastViewManager != 0)
// {
// bool stacksWereRestored = fastViewManager.restoreAllTrimStacks();
// setEditorAreaTrimVisibility(false);
//
// // Restore any 'maximized' view stack since we've restored
// // the minimized stacks
// if (stacksWereRestored && presentation.getMaximizedStack().Cast() != 0)
// {
// ViewStack vs = (ViewStack) presentation.getMaximizedStack();
// vs.setPresentationState(IStackPresentationSite.STATE_RESTORED);
// presentation.setMaximizedStack(0);
// }
// }
// We hide the editor area -after- the presentation activates
if (hideEditorArea)
{
// We do this here to ensure that createPartControl is called on the
// top editor
// before it is hidden. See bug 20166.
this->HideEditorArea();
shouldHideEditorsOnActivate = false;
// // this is an override so it should handle both states
// if (useNewMinMax)
// setEditorAreaTrimVisibility(editorAreaState == IStackPresentationSite.STATE_MINIMIZED);
}
FixOrphan();
}
void Perspective::FixOrphan()
{
PerspectiveRegistry* reg = static_cast(PlatformUI::GetWorkbench()->GetPerspectiveRegistry());
IPerspectiveDescriptor::Pointer regDesc = reg->FindPerspectiveWithId(descriptor->GetId());
if (regDesc.IsNull())
{
QString msg = "Perspective " + descriptor->GetLabel() + " has been made into a local copy";
IStatus::Pointer status = StatusUtil::NewStatus(IStatus::WARNING_TYPE, msg, BERRY_STATUS_LOC);
//StatusManager.getManager().handle(status, StatusManager.LOG);
WorkbenchPlugin::Log(status);
QString localCopyLabel("<%1>");
QString newDescId = localCopyLabel.arg(descriptor->GetLabel());
while (reg->FindPerspectiveWithId(newDescId).IsNotNull())
{
newDescId = localCopyLabel.arg(newDescId);
}
- PerspectiveDescriptor::Pointer newDesc = reg->CreatePerspective(newDescId, descriptor);
+ IPerspectiveDescriptor::Pointer newDesc = reg->CreatePerspective(newDescId, descriptor);
page->SavePerspectiveAs(newDesc);
}
}
void Perspective::OnDeactivate()
{
presentation->Deactivate();
//setActiveFastView(0);
//setAllPinsVisible(false);
// // Update fast views.
// if (fastViewManager != 0)
// {
// List fastViews = fastViewManager.getFastViews(0);
// for (int i = 0; i < fastViews.size(); i++)
// {
// ViewPane pane = getPane((IViewReference) fastViews.get(i));
// if (pane != 0)
// {
// Control ctrl = pane.getControl();
// if (ctrl != 0)
// {
// ctrl.setEnabled(true); // Add focus support.
// }
// }
// }
//
// fastViewManager.deActivate();
// }
//
// // Ensure that the editor area trim is hidden as well
// setEditorAreaTrimVisibility(false);
}
void Perspective::PartActivated(IWorkbenchPart::Pointer /*activePart*/)
{
// // If a fastview is open close it.
// if (activeFastView != 0
// && activeFastView.getPart(false) != activePart)
// {
// setActiveFastView(0);
// }
}
void Perspective::PerformedShowIn(const QString& /*partId*/)
{
//showInTimes.insert(std::make_pair(partId, new Long(System.currentTimeMillis())));
}
bool Perspective::RestoreState(IMemento::Pointer memento)
{
// MultiStatus result = new MultiStatus(
// PlatformUI.PLUGIN_ID,
// IStatus.OK,
// WorkbenchMessages.Perspective_problemsRestoringPerspective, 0);
bool result = true;
// Create persp descriptor.
descriptor = new PerspectiveDescriptor("", "", PerspectiveDescriptor::Pointer(0));
//result.add(descriptor.restoreState(memento));
result &= descriptor->RestoreState(memento);
PerspectiveDescriptor::Pointer desc = WorkbenchPlugin::GetDefault()->
GetPerspectiveRegistry()->FindPerspectiveWithId(descriptor->GetId()).Cast();
if (desc)
{
descriptor = desc;
}
else
{
try
{
WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()->CreatePerspective(descriptor->GetLabel(), descriptor.Cast());
}
catch (...)
{
std::cout << "Perspective could not be loaded" << std::endl;
}
}
this->memento = memento;
// Add the visible views.
QList views(memento->GetChildren(WorkbenchConstants::TAG_VIEW));
//result.merge(createReferences(views));
result &= this->CreateReferences(views);
memento = memento->GetChild(WorkbenchConstants::TAG_FAST_VIEWS);
if (memento)
{
views = memento->GetChildren(WorkbenchConstants::TAG_VIEW);
//result.merge(createReferences(views));
result &= this->CreateReferences(views);
}
return result;
}
bool Perspective::CreateReferences(const QList& views)
{
// MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
// WorkbenchMessages.Perspective_problemsRestoringViews, 0);
bool result = true;
for (int x = 0; x < views.size(); x++)
{
// Get the view details.
IMemento::Pointer childMem = views[x];
QString id; childMem->GetString(WorkbenchConstants::TAG_ID, id);
// skip creation of the intro reference - it's handled elsewhere.
if (id == IntroConstants::INTRO_VIEW_ID)
{
continue;
}
QString secondaryId(ViewFactory::ExtractSecondaryId(id));
if (!secondaryId.isEmpty())
{
id = ViewFactory::ExtractPrimaryId(id);
}
// Create and open the view.
try
{
QString rm; childMem->GetString(WorkbenchConstants::TAG_REMOVED, rm);
if (rm != "true")
{
viewFactory->CreateView(id, secondaryId);
}
}
catch (const PartInitException& e)
{
childMem->PutString(WorkbenchConstants::TAG_REMOVED, "true");
// result.add(StatusUtil.newStatus(IStatus.ERR,
// e.getMessage() == 0 ? "" : e.getMessage(), //$NON-NLS-1$
// e));
WorkbenchPlugin::Log(e.what(), e);
result &= true;
}
}
return result;
}
bool Perspective::RestoreState()
{
if (this->memento == 0)
{
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0); //$NON-NLS-1$
return true;
}
// MultiStatus result = new MultiStatus(
// PlatformUI.PLUGIN_ID,
// IStatus.OK,
// WorkbenchMessages.Perspective_problemsRestoringPerspective, 0);
bool result = true;
IMemento::Pointer memento = this->memento;
this->memento = 0;
const IMemento::Pointer boundsMem(memento->GetChild(WorkbenchConstants::TAG_WINDOW));
if (boundsMem)
{
Rectangle r(0, 0, 0, 0);
boundsMem->GetInteger(WorkbenchConstants::TAG_X, r.x);
boundsMem->GetInteger(WorkbenchConstants::TAG_Y, r.y);
boundsMem->GetInteger(WorkbenchConstants::TAG_HEIGHT, r.height);
boundsMem->GetInteger(WorkbenchConstants::TAG_WIDTH, r.width);
//StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// void runWithException() throws Throwable
// {
if (page->GetWorkbenchWindow()->GetActivePage() == 0)
{
page->GetWorkbenchWindow()->GetShell()->SetBounds(r);
}
// }
// });
}
// Create an empty presentation..
PerspectiveHelper* pres;
//StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// void runWithException() throws Throwable
// {
ViewSashContainer::Pointer mainLayout(new ViewSashContainer(page, this->GetClientComposite()));
pres = new PerspectiveHelper(page, mainLayout, this);
// }});
// Read the layout.
// result.merge(pres.restoreState(memento
// .getChild(IWorkbenchConstants.TAG_LAYOUT)));
result &= pres->RestoreState(memento->GetChild(WorkbenchConstants::TAG_LAYOUT));
//StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// void runWithException() throws Throwable
// {
// Add the editor workbook. Do not hide it now.
pres->ReplacePlaceholderWithPart(editorArea);
// }});
// Add the visible views.
QList views(memento->GetChildren(WorkbenchConstants::TAG_VIEW));
for (int x = 0; x < views.size(); x++)
{
// Get the view details.
IMemento::Pointer childMem = views[x];
QString id; childMem->GetString(WorkbenchConstants::TAG_ID, id);
QString secondaryId(ViewFactory::ExtractSecondaryId(id));
if (!secondaryId.isEmpty())
{
id = ViewFactory::ExtractPrimaryId(id);
}
// skip the intro as it is restored higher up in workbench.
if (id == IntroConstants::INTRO_VIEW_ID)
{
continue;
}
// Create and open the view.
IViewReference::Pointer viewRef = viewFactory->GetView(id, secondaryId);
WorkbenchPartReference::Pointer ref = viewRef.Cast();
// report error
if (ref == 0)
{
QString key = ViewFactory::GetKey(id, secondaryId);
// result.add(new Status(IStatus.ERR, PlatformUI.PLUGIN_ID, 0,
// NLS.bind(WorkbenchMessages.Perspective_couldNotFind, key ), 0));
WorkbenchPlugin::Log("Could not find view: " + key);
continue;
}
bool willPartBeVisible = pres->WillPartBeVisible(ref->GetId(), secondaryId);
if (willPartBeVisible)
{
IViewPart::Pointer view = ref->GetPart(true).Cast();
if (view)
{
ViewSite::Pointer site = view->GetSite().Cast();
pres->ReplacePlaceholderWithPart(site->GetPane().Cast());
}
}
else
{
pres->ReplacePlaceholderWithPart(ref->GetPane());
}
}
// // Load the fast views
// if (fastViewManager != 0)
// fastViewManager.restoreState(memento, result);
// Load the view layout recs
QList recMementos(memento
->GetChildren(WorkbenchConstants::TAG_VIEW_LAYOUT_REC));
for (int i = 0; i < recMementos.size(); i++)
{
IMemento::Pointer recMemento = recMementos[i];
QString compoundId;
if (recMemento->GetString(WorkbenchConstants::TAG_ID, compoundId))
{
ViewLayoutRec::Pointer rec = GetViewLayoutRec(compoundId, true);
QString closeablestr; recMemento->GetString(WorkbenchConstants::TAG_CLOSEABLE, closeablestr);
if (WorkbenchConstants::FALSE_VAL == closeablestr)
{
rec->isCloseable = false;
}
QString moveablestr; recMemento->GetString(WorkbenchConstants::TAG_MOVEABLE, moveablestr);
if (WorkbenchConstants::FALSE_VAL == moveablestr)
{
rec->isMoveable = false;
}
QString standalonestr; recMemento->GetString(WorkbenchConstants::TAG_STANDALONE, standalonestr);
if (WorkbenchConstants::TRUE_VAL == standalonestr)
{
rec->isStandalone = true;
QString showstr; recMemento->GetString(WorkbenchConstants::TAG_SHOW_TITLE, showstr);
rec->showTitle = WorkbenchConstants::FALSE_VAL != showstr;
}
}
}
//final IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
try
{ // one big try block, don't kill me here
// // defer context events
// if (service != 0)
// {
// service.activateContext(ContextAuthority.DEFER_EVENTS);
// }
//
// HashSet knownActionSetIds = new HashSet();
//
// // Load the always on action sets.
QList actions; // = memento
// .getChildren(IWorkbenchConstants.TAG_ALWAYS_ON_ACTION_SET);
// for (int x = 0; x < actions.length; x++)
// {
// String actionSetID = actions[x]
// .getString(IWorkbenchConstants.TAG_ID);
// final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
// .getActionSetRegistry().findActionSet(actionSetID);
// if (d != 0)
// {
// StartupThreading
// .runWithoutExceptions(new StartupRunnable()
// {
// void runWithException() throws Throwable
// {
// addAlwaysOn(d);
// }
// });
//
// knownActionSetIds.add(actionSetID);
// }
// }
//
// // Load the always off action sets.
// actions = memento
// .getChildren(IWorkbenchConstants.TAG_ALWAYS_OFF_ACTION_SET);
// for (int x = 0; x < actions.length; x++)
// {
// String actionSetID = actions[x]
// .getString(IWorkbenchConstants.TAG_ID);
// final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
// .getActionSetRegistry().findActionSet(actionSetID);
// if (d != 0)
// {
// StartupThreading
// .runWithoutExceptions(new StartupRunnable()
// {
// void runWithException() throws Throwable
// {
// addAlwaysOff(d);
// }
// });
// knownActionSetIds.add(actionSetID);
// }
// }
// Load "show view actions".
actions = memento->GetChildren(WorkbenchConstants::TAG_SHOW_VIEW_ACTION);
for (int x = 0; x < actions.size(); x++)
{
QString id; actions[x]->GetString(WorkbenchConstants::TAG_ID, id);
showViewShortcuts.push_back(id);
}
// // Load "show in times".
// actions = memento.getChildren(IWorkbenchConstants.TAG_SHOW_IN_TIME);
// for (int x = 0; x < actions.length; x++)
// {
// String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
// String timeStr = actions[x]
// .getString(IWorkbenchConstants.TAG_TIME);
// if (id != 0 && timeStr != 0)
// {
// try
// {
// long time = Long.parseLong(timeStr);
// showInTimes.put(id, new Long(time));
// }
// catch (NumberFormatException e)
// {
// // skip this one
// }
// }
// }
// Load "show in parts" from registry, not memento
showInPartIds = this->GetShowInIdsFromRegistry();
// // Load "new wizard actions".
// actions = memento
// .getChildren(IWorkbenchConstants.TAG_NEW_WIZARD_ACTION);
// newWizardShortcuts = new ArrayList(actions.length);
// for (int x = 0; x < actions.length; x++)
// {
// String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
// newWizardShortcuts.add(id);
// }
// Load "perspective actions".
actions = memento->GetChildren(WorkbenchConstants::TAG_PERSPECTIVE_ACTION);
for (int x = 0; x < actions.size(); x++)
{
QString id; actions[x]->GetString(WorkbenchConstants::TAG_ID, id);
perspectiveShortcuts.push_back(id);
}
// ArrayList extActionSets = getPerspectiveExtensionActionSets();
// for (int i = 0; i < extActionSets.size(); i++)
// {
// String actionSetID = (String) extActionSets.get(i);
// if (knownActionSetIds.contains(actionSetID))
// {
// continue;
// }
// final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
// .getActionSetRegistry().findActionSet(actionSetID);
// if (d != 0)
// {
// StartupThreading
// .runWithoutExceptions(new StartupRunnable()
// {
// void runWithException() throws Throwable
// {
// addAlwaysOn(d);
// }
// });
// knownActionSetIds.add(d.getId());
// }
// }
// // Add the visible set of action sets to our knownActionSetIds
// // Now go through the registry to ensure we pick up any new action
// // sets
// // that have been added but not yet considered by this perspective.
// ActionSetRegistry reg = WorkbenchPlugin.getDefault()
// .getActionSetRegistry();
// IActionSetDescriptor[] array = reg.getActionSets();
// int count = array.length;
// for (int i = 0; i < count; i++)
// {
// IActionSetDescriptor desc = array[i];
// if ((!knownActionSetIds.contains(desc.getId()))
// && (desc.isInitiallyVisible()))
// {
// addActionSet(desc);
// }
// }
}
catch (...)
{
// // restart context changes
// if (service != 0)
// {
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// void runWithException() throws Throwable
// {
// service.activateContext(ContextAuthority.SEND_EVENTS);
// }
// });
// }
}
// Save presentation.
presentation = pres;
// Hide the editor area if needed. Need to wait for the
// presentation to be fully setup first.
int areaVisible = 0;
bool areaVisibleExists = memento->GetInteger(WorkbenchConstants::TAG_AREA_VISIBLE, areaVisible);
// Rather than hiding the editors now we must wait until after their
// controls
// are created. This ensures that if an editor is instantiated,
// createPartControl
// is also called. See bug 20166.
shouldHideEditorsOnActivate = (areaVisibleExists && areaVisible == 0);
// // Restore the trim state of the editor area
// IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
// bool useNewMinMax = preferenceStore.getbool(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
// if (useNewMinMax)
// {
// Integer trimStateInt = memento.getInteger(IWorkbenchConstants.TAG_AREA_TRIM_STATE);
// if (trimStateInt != 0)
// {
// editorAreaState = trimStateInt.intValue() & 0x3; // low order two bits contain the state
// editorAreaRestoreOnUnzoom = (trimStateInt.intValue() & 4) != 0;
// }
// }
// restore the fixed state
int isFixed = 0;
fixed = (memento->GetInteger(WorkbenchConstants::TAG_FIXED, isFixed) && isFixed == 1);
return true;
}
QList Perspective::GetShowInIdsFromRegistry()
{
PerspectiveExtensionReader reader;
QList tags;
tags.push_back(WorkbenchRegistryConstants::TAG_SHOW_IN_PART);
reader.SetIncludeOnlyTags(tags);
PageLayout::Pointer layout(new PageLayout());
reader.ExtendLayout(descriptor->GetOriginalId(), layout);
return layout->GetShowInPartIds();
}
void Perspective::SaveDesc()
{
this->SaveDescAs(descriptor);
}
void Perspective::SaveDescAs(IPerspectiveDescriptor::Pointer /*desc*/)
{
//TODO Perspective SaveDescAs
// PerspectiveDescriptor::Pointer realDesc = desc.Cast();
// //get the layout from the registry
// PerspectiveRegistry* perspRegistry = dynamic_cast(WorkbenchPlugin
// ::GetDefault()->GetPerspectiveRegistry());
// // Capture the layout state.
// XMLMemento memento = XMLMemento.createWriteRoot("perspective");//$NON-NLS-1$
// IStatus status = saveState(memento, realDesc, false);
// if (status.getSeverity() == IStatus.ERR)
// {
// ErrorDialog.openError((Shell) 0, WorkbenchMessages.Perspective_problemSavingTitle,
// WorkbenchMessages.Perspective_problemSavingMessage,
// status);
// return;
// }
// //save it to the preference store
// try
// {
// perspRegistry.saveCustomPersp(realDesc, memento);
// descriptor = realDesc;
// }
// catch (IOException e)
// {
// perspRegistry.deletePerspective(realDesc);
// MessageDialog.openError((Shell) 0, WorkbenchMessages.Perspective_problemSavingTitle,
// WorkbenchMessages.Perspective_problemSavingMessage);
// }
}
bool Perspective::SaveState(IMemento::Pointer memento)
{
// MultiStatus result = new MultiStatus(
// PlatformUI.PLUGIN_ID,
// IStatus.OK,
// WorkbenchMessages.Perspective_problemsSavingPerspective, 0);
//
// result.merge(saveState(memento, descriptor, true));
bool result = true;
result &= this->SaveState(memento, descriptor, true);
return result;
}
bool Perspective::SaveState(IMemento::Pointer memento, PerspectiveDescriptor::Pointer p,
bool saveInnerViewState)
{
// MultiStatus result = new MultiStatus(
// PlatformUI.PLUGIN_ID,
// IStatus.OK,
// WorkbenchMessages.Perspective_problemsSavingPerspective, 0);
bool result = true;
if (this->memento)
{
memento->PutMemento(this->memento);
return result;
}
// Save the version number.
memento->PutString(WorkbenchConstants::TAG_VERSION, VERSION_STRING);
//result.add(p.saveState(memento));
result &= p->SaveState(memento);
if (!saveInnerViewState)
{
Rectangle bounds(page->GetWorkbenchWindow()->GetShell()->GetBounds());
IMemento::Pointer boundsMem = memento
->CreateChild(WorkbenchConstants::TAG_WINDOW);
boundsMem->PutInteger(WorkbenchConstants::TAG_X, bounds.x);
boundsMem->PutInteger(WorkbenchConstants::TAG_Y, bounds.y);
boundsMem->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height);
boundsMem->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width);
}
// // Save the "always on" action sets.
// Iterator itr = alwaysOnActionSets.iterator();
// while (itr.hasNext())
// {
// IActionSetDescriptor desc = (IActionSetDescriptor) itr.next();
// IMemento child = memento
// .createChild(IWorkbenchConstants.TAG_ALWAYS_ON_ACTION_SET);
// child.putString(IWorkbenchConstants.TAG_ID, desc.getId());
// }
// // Save the "always off" action sets.
// itr = alwaysOffActionSets.iterator();
// while (itr.hasNext())
// {
// IActionSetDescriptor desc = (IActionSetDescriptor) itr.next();
// IMemento child = memento
// .createChild(IWorkbenchConstants.TAG_ALWAYS_OFF_ACTION_SET);
// child.putString(IWorkbenchConstants.TAG_ID, desc.getId());
// }
// Save "show view actions"
for (QList::iterator itr = showViewShortcuts.begin();
itr != showViewShortcuts.end(); ++itr)
{
IMemento::Pointer child = memento
->CreateChild(WorkbenchConstants::TAG_SHOW_VIEW_ACTION);
child->PutString(WorkbenchConstants::TAG_ID, *itr);
}
// // Save "show in times"
// itr = showInTimes.keySet().iterator();
// while (itr.hasNext())
// {
// String id = (String) itr.next();
// Long time = (Long) showInTimes.get(id);
// IMemento child = memento
// .createChild(IWorkbenchConstants.TAG_SHOW_IN_TIME);
// child.putString(IWorkbenchConstants.TAG_ID, id);
// child.putString(IWorkbenchConstants.TAG_TIME, time.toString());
// }
// // Save "new wizard actions".
// itr = newWizardShortcuts.iterator();
// while (itr.hasNext())
// {
// String str = (String) itr.next();
// IMemento child = memento
// .createChild(IWorkbenchConstants.TAG_NEW_WIZARD_ACTION);
// child.putString(IWorkbenchConstants.TAG_ID, str);
// }
// Save "perspective actions".
for (QList::iterator itr = perspectiveShortcuts.begin();
itr != perspectiveShortcuts.end(); ++itr)
{
IMemento::Pointer child = memento
->CreateChild(WorkbenchConstants::TAG_PERSPECTIVE_ACTION);
child->PutString(WorkbenchConstants::TAG_ID, *itr);
}
// Get visible views.
QList viewPanes;
presentation->CollectViewPanes(viewPanes);
// Save the views.
for (QList::iterator itr = viewPanes.begin();
itr != viewPanes.end(); ++itr)
{
IWorkbenchPartReference::Pointer ref((*itr)->GetPartReference());
IViewDescriptor::Pointer desc = page->GetViewFactory()->GetViewRegistry()
->Find(ref->GetId());
if(desc && desc->IsRestorable())
{
IMemento::Pointer viewMemento = memento
->CreateChild(WorkbenchConstants::TAG_VIEW);
viewMemento->PutString(WorkbenchConstants::TAG_ID, ViewFactory::GetKey(ref.Cast()));
}
}
// // save all fastview state
// if (fastViewManager != 0)
// fastViewManager.saveState(memento);
// Save the view layout recs.
for (QHash::iterator i = mapIDtoViewLayoutRec.begin();
i != mapIDtoViewLayoutRec.end(); ++i)
{
QString compoundId(i.key());
ViewLayoutRec::Pointer rec(i.value());
if (rec && (!rec->isCloseable || !rec->isMoveable || rec->isStandalone))
{
IMemento::Pointer layoutMemento(memento
->CreateChild(WorkbenchConstants::TAG_VIEW_LAYOUT_REC));
layoutMemento->PutString(WorkbenchConstants::TAG_ID, compoundId);
if (!rec->isCloseable)
{
layoutMemento->PutString(WorkbenchConstants::TAG_CLOSEABLE,
WorkbenchConstants::FALSE_VAL);
}
if (!rec->isMoveable)
{
layoutMemento->PutString(WorkbenchConstants::TAG_MOVEABLE,
WorkbenchConstants::FALSE_VAL);
}
if (rec->isStandalone)
{
layoutMemento->PutString(WorkbenchConstants::TAG_STANDALONE,
WorkbenchConstants::TRUE_VAL);
layoutMemento->PutString(WorkbenchConstants::TAG_SHOW_TITLE,
rec->showTitle ? WorkbenchConstants::TRUE_VAL : WorkbenchConstants::FALSE_VAL);
}
}
}
// Save the layout.
IMemento::Pointer childMem(memento->CreateChild(WorkbenchConstants::TAG_LAYOUT));
//result.add(presentation.saveState(childMem));
result &= presentation->SaveState(childMem);
// Save the editor visibility state
if (this->IsEditorAreaVisible())
{
memento->PutInteger(WorkbenchConstants::TAG_AREA_VISIBLE, 1);
}
else
{
memento->PutInteger(WorkbenchConstants::TAG_AREA_VISIBLE, 0);
}
// // Save the trim state of the editor area if using the new min/max
// IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
// bool useNewMinMax = preferenceStore.getbool(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
// if (useNewMinMax)
// {
// int trimState = editorAreaState;
// trimState |= editorAreaRestoreOnUnzoom ? 4 : 0;
// memento.putInteger(IWorkbenchConstants.TAG_AREA_TRIM_STATE, trimState);
// }
// Save the fixed state
if (fixed)
{
memento->PutInteger(WorkbenchConstants::TAG_FIXED, 1);
}
else
{
memento->PutInteger(WorkbenchConstants::TAG_FIXED, 0);
}
return result;
}
void Perspective::SetPerspectiveActionIds(const QList& list)
{
perspectiveShortcuts = list;
}
void Perspective::SetShowInPartIds(const QList& list)
{
showInPartIds = list;
}
void Perspective::SetShowViewActionIds(const QList& list)
{
showViewShortcuts = list;
}
void Perspective::ShowEditorArea()
{
if (this->IsEditorAreaVisible())
{
return;
}
editorHidden = false;
// Show the editor in the appropriate location
if (this->UseNewMinMax(Perspective::Pointer(this)))
{
bool isMinimized = editorAreaState == IStackPresentationSite::STATE_MINIMIZED;
if (!isMinimized)
{
// If the editor area is going to show then we have to restore
// if (getPresentation().getMaximizedStack() != 0)
// getPresentation().getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED);
this->ShowEditorAreaLocal();
}
// else
// setEditorAreaTrimVisibility(true);
}
else
{
this->ShowEditorAreaLocal();
}
}
void Perspective::ShowEditorAreaLocal()
{
if (editorHolder == 0 || editorHidden)
{
return;
}
// Replace the part holder with the editor area.
presentation->GetLayout()->Replace(editorHolder, editorArea);
editorHolder = 0;
}
void Perspective::SetEditorAreaState(int newState)
{
if (newState == editorAreaState)
return;
editorAreaState = newState;
// // reset the restore flag if we're not minimized
// if (newState != IStackPresentationSite::STATE_MINIMIZED)
// editorAreaRestoreOnUnzoom = false;
this->RefreshEditorAreaVisibility();
}
int Perspective::GetEditorAreaState()
{
return editorAreaState;
}
void Perspective::RefreshEditorAreaVisibility()
{
// Nothing shows up if the editor area isn't visible at all
if (editorHidden)
{
this->HideEditorAreaLocal();
//setEditorAreaTrimVisibility(false);
return;
}
PartStack::Pointer editorStack = editorArea.Cast()->GetUpperRightEditorStack();
if (editorStack == 0)
return;
// Whatever we're doing, make the current editor stack match it
//editorStack->SetStateLocal(editorAreaState);
// If it's minimized then it's in the trim
if (editorAreaState == IStackPresentationSite::STATE_MINIMIZED)
{
// Hide the editor area and show its trim
this->HideEditorAreaLocal();
//setEditorAreaTrimVisibility(true);
}
else
{
// Show the editor area and hide its trim
//setEditorAreaTrimVisibility(false);
this->ShowEditorAreaLocal();
// if (editorAreaState == IStackPresentationSite::STATE_MAXIMIZED)
// getPresentation().setMaximizedStack(editorStack);
}
}
IViewReference::Pointer Perspective::GetViewReference(const QString& viewId, const QString& secondaryId)
{
IViewReference::Pointer ref = page->FindViewReference(viewId, secondaryId);
if (ref == 0)
{
ViewFactory* factory = this->GetViewFactory();
try
{
ref = factory->CreateView(viewId, secondaryId);
}
catch (PartInitException& /*e*/)
{
// IStatus status = StatusUtil.newStatus(IStatus.ERR,
// e.getMessage() == 0 ? "" : e.getMessage(), //$NON-NLS-1$
// e);
// StatusUtil.handleStatus(status, "Failed to create view: id=" + viewId, //$NON-NLS-1$
// StatusManager.LOG);
//TODO Perspective status message
WorkbenchPlugin::Log("Failed to create view: id=" + viewId);
}
}
return ref;
}
IViewPart::Pointer Perspective::ShowView(const QString& viewId, const QString& secondaryId)
{
ViewFactory* factory = this->GetViewFactory();
IViewReference::Pointer ref = factory->CreateView(viewId, secondaryId);
IViewPart::Pointer part = ref->GetPart(true).Cast();
if (part == 0)
{
throw PartInitException("Could not create view: " + ref->GetId());
}
PartSite::Pointer site = part->GetSite().Cast();
PartPane::Pointer pane = site->GetPane();
//TODO Perspective preference store
// IPreferenceStore store = WorkbenchPlugin.getDefault()
// .getPreferenceStore();
// int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE);
//
// if (openViewMode == IPreferenceConstants.OVM_FAST &&
// fastViewManager != 0)
// {
// fastViewManager.addViewReference(FastViewBar.FASTVIEWBAR_ID, -1, ref, true);
// setActiveFastView(ref);
// }
// else if (openViewMode == IPreferenceConstants.OVM_FLOAT
// && presentation.canDetach())
// {
// presentation.addDetachedPart(pane);
// }
// else
// {
if (this->UseNewMinMax(Perspective::Pointer(this)))
{
// Is this view going to show in the trim?
// LayoutPart vPart = presentation.findPart(viewId, secondaryId);
// Determine if there is a trim stack that should get the view
QString trimId;
// // If we can locate the correct trim stack then do so
// if (vPart != 0)
// {
// String id = 0;
// ILayoutContainer container = vPart.getContainer();
// if (container.Cast() != 0)
// id = ((ContainerPlaceholder)container).getID();
// else if (container.Cast() != 0)
// id = ((ViewStack)container).getID();
//
// // Is this place-holder in the trim?
// if (id != 0 && fastViewManager.getFastViews(id).size()> 0)
// {
// trimId = id;
// }
// }
//
// // No explicit trim found; If we're maximized then we either have to find an
// // arbitrary stack...
// if (trimId == 0 && presentation.getMaximizedStack() != 0)
// {
// if (vPart == 0)
// {
// ViewStackTrimToolBar blTrimStack = fastViewManager.getBottomRightTrimStack();
// if (blTrimStack != 0)
// {
// // OK, we've found a trim stack to add it to...
// trimId = blTrimStack.getId();
//
// // Since there was no placeholder we have to add one
// LayoutPart blPart = presentation.findPart(trimId, 0);
// if (blPart.Cast() != 0)
// {
// ContainerPlaceholder cph = (ContainerPlaceholder) blPart;
// if (cph.getRealContainer().Cast() != 0)
// {
// ViewStack vs = (ViewStack) cph.getRealContainer();
//
// // Create a 'compound' id if this is a multi-instance part
// String compoundId = ref.getId();
// if (ref.getSecondaryId() != 0)
// compoundId = compoundId + ':' + ref.getSecondaryId();
//
// // Add the new placeholder
// vs.add(new PartPlaceholder(compoundId));
// }
// }
// }
// }
// }
//
// // If we have a trim stack located then add the view to it
// if (trimId != "")
// {
// fastViewManager.addViewReference(trimId, -1, ref, true);
// }
// else
// {
// bool inMaximizedStack = vPart != 0 && vPart.getContainer() == presentation.getMaximizedStack();
// Do the default behavior
presentation->AddPart(pane);
// // Now, if we're maximized then we have to minimize the new stack
// if (presentation.getMaximizedStack() != 0 && !inMaximizedStack)
// {
// vPart = presentation.findPart(viewId, secondaryId);
// if (vPart != 0 && vPart.getContainer().Cast() != 0)
// {
// ViewStack vs = (ViewStack)vPart.getContainer();
// vs.setState(IStackPresentationSite.STATE_MINIMIZED);
//
// // setting the state to minimized will create the trim toolbar
// // so we don't need a 0 pointer check here...
// fastViewManager.getViewStackTrimToolbar(vs.getID()).setRestoreOnUnzoom(true);
// }
// }
// }
}
else
{
presentation->AddPart(pane);
}
//}
// Ensure that the newly showing part is enabled
if (pane != 0 && pane->GetControl() != 0)
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(pane->GetControl(), true);
return part;
}
IWorkbenchPartReference::Pointer Perspective::GetOldPartRef()
{
return oldPartRef;
}
void Perspective::SetOldPartRef(IWorkbenchPartReference::Pointer oldPartRef)
{
this->oldPartRef = oldPartRef;
}
bool Perspective::IsCloseable(IViewReference::Pointer reference)
{
ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(reference, false);
if (rec != 0)
{
return rec->isCloseable;
}
return true;
}
bool Perspective::IsMoveable(IViewReference::Pointer reference)
{
ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(reference, false);
if (rec != 0)
{
return rec->isMoveable;
}
return true;
}
void Perspective::DescribeLayout(QString& buf) const
{
// QList fastViews = getFastViews();
//
// if (fastViews.length != 0)
// {
// buf.append("fastviews ("); //$NON-NLS-1$
// for (int idx = 0; idx < fastViews.length; idx++)
// {
// IViewReference ref = fastViews[idx];
//
// if (idx> 0)
// {
// buf.append(", "); //$NON-NLS-1$
// }
//
// buf.append(ref.getPartName());
// }
// buf.append("), "); //$NON-NLS-1$
// }
this->GetPresentation()->DescribeLayout(buf);
}
void Perspective::TestInvariants()
{
this->GetPresentation()->GetLayout()->TestInvariants();
}
bool Perspective::UseNewMinMax(Perspective::Pointer activePerspective)
{
// We need to have an active perspective
if (activePerspective == 0)
return false;
// We need to have a trim manager (if we don't then we
// don't create a FastViewManager because it'd be useless)
// if (activePerspective->GetFastViewManager() == 0)
// return false;
// Make sure we don't NPE anyplace
WorkbenchWindow::Pointer wbw = activePerspective->page->GetWorkbenchWindow().Cast();
if (wbw == 0)
return false;
// WorkbenchWindowConfigurer* configurer = wbw->GetWindowConfigurer();
// if (configurer == 0)
// return false;
IPresentationFactory* factory = WorkbenchPlugin::GetDefault()->GetPresentationFactory();
if (factory == 0)
return false;
// Ok, we should be good to go, return the pref
//IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
//bool useNewMinMax = preferenceStore.getbool(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX);
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspective.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspective.h
index 77eab7d072..422863a217 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspective.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspective.h
@@ -1,636 +1,636 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPERSPECTIVE_H_
#define BERRYPERSPECTIVE_H_
#include
#include "berryPerspectiveDescriptor.h"
#include "berryPartPlaceholder.h"
#include "berryViewLayoutRec.h"
#include "berryWorkbenchPage.h"
#include "berryLayoutPart.h"
#include "berryPageLayout.h"
#include "berryPartPane.h"
#include "berryIWorkbenchPartReference.h"
#include "berryIViewReference.h"
#include "berryIViewPart.h"
namespace berry {
class ViewFactory;
class PerspectiveHelper;
/**
* \ingroup org_blueberry_ui_internal
*
*/
class Perspective : public Object {
public:
berryObjectMacro(Perspective)
friend class WorkbenchPage;
- bool ContainsView(const std::string& viewId);
+ bool ContainsView(const QString& viewId) const;
private:
ViewFactory* viewFactory;
QHash mapIDtoViewLayoutRec;
static const QString VERSION_STRING; // = "0.016";
/**
* Reference to the part that was previously active
* when this perspective was deactivated.
*/
IWorkbenchPartReference::Pointer oldPartRef;
protected:
PerspectiveDescriptor::Pointer descriptor;
WorkbenchPage* page;
// Editor Area management
LayoutPart::Pointer editorArea;
PartPlaceholder::Pointer editorHolder;
bool editorHidden;
int editorAreaState;
//ArrayList alwaysOnActionSets;
//ArrayList alwaysOffActionSets;
QList showViewShortcuts;
QList perspectiveShortcuts;
bool fixed;
QList showInPartIds;
//HashMap showInTimes;
IMemento::Pointer memento;
PerspectiveHelper* presentation;
bool shouldHideEditorsOnActivate;
PageLayout::Pointer layout;
/**
* ViewManager constructor comment.
*/
public: Perspective(PerspectiveDescriptor::Pointer desc, WorkbenchPage::Pointer page);
/**
* ViewManager constructor comment.
*/
protected: Perspective(WorkbenchPage::Pointer page);
protected: void Init(WorkbenchPage::Pointer page);
/**
* Moves a part forward in the Z order of a perspective so it is visible.
*
* @param part the part to bring to move forward
* @return true if the part was brought to top, false if not.
*/
public: bool BringToTop(IViewReference::Pointer ref);
/**
* Returns whether a view exists within the perspective.
*/
public: bool ContainsView(IViewPart::Pointer view);
/**
* Create the initial list of action sets.
*/
// protected: void CreateInitialActionSets(List outputList, List stringList) {
// ActionSetRegistry reg = WorkbenchPlugin.getDefault()
// .getActionSetRegistry();
// Iterator iter = stringList.iterator();
// while (iter.hasNext()) {
// String id = (String) iter.next();
// IActionSetDescriptor desc = reg.findActionSet(id);
// if (desc != null) {
// outputList.add(desc);
// } else {
// WorkbenchPlugin.log("Unable to find Action Set: " + id);//$NON-NLS-1$
// }
// }
// }
/**
* Create a presentation for a perspective.
*/
private: void CreatePresentation(PerspectiveDescriptor::Pointer persp);
/**
* Dispose the perspective and all views contained within.
*/
public: ~Perspective();
private: void DisposeViewRefs();
/**
* Finds the view with the given ID that is open in this page, or null
* if not found.
*
* @param viewId the view ID
*/
public: IViewReference::Pointer FindView(const QString& viewId);
/**
* Finds the view with the given id and secondary id that is open in this page,
* or null
if not found.
*
* @param viewId the view ID
* @param secondaryId the secondary ID
*/
public: IViewReference::Pointer FindView(const QString& id, const QString& secondaryId);
/**
* Returns the window's client composite widget
* which views and editor area will be parented.
*/
public: void* GetClientComposite();
/**
* Returns the perspective.
*/
public: IPerspectiveDescriptor::Pointer GetDesc();
/**
* Returns the pane for a view reference.
*/
protected: PartPane::Pointer GetPane(IViewReference::Pointer ref);
/**
* Returns the perspective shortcuts associated with this perspective.
*
* @return an array of perspective identifiers
*/
public: QList GetPerspectiveShortcuts();
/**
* Returns the presentation.
*/
public: PerspectiveHelper* GetPresentation() const;
/**
* Returns the show view shortcuts associated with this perspective.
*
* @return an array of view identifiers
*/
public: QList GetShowViewShortcuts();
/**
* Returns the view factory.
*/
public: ViewFactory* GetViewFactory();
/**
* See IWorkbenchPage.
*/
public: QList GetViewReferences();
/**
* Hide the editor area if visible
*/
protected: void HideEditorArea();
/**
* Hide the editor area if visible
*/
protected: void HideEditorAreaLocal();
public: bool HideView(IViewReference::Pointer ref);
/*
* Return whether the editor area is visible or not.
*/
protected: bool IsEditorAreaVisible();
/**
* Returns the view layout rec for the given view reference,
* or null if not found. If create is true, it creates the record
* if not already created.
*/
public: ViewLayoutRec::Pointer GetViewLayoutRec(IViewReference::Pointer ref, bool create);
/**
* Returns the view layout record for the given view id
* or null if not found. If create is true, it creates the record
* if not already created.
*/
private: ViewLayoutRec::Pointer GetViewLayoutRec(const QString& viewId, bool create);
/**
* Returns true if a layout or perspective is fixed.
*/
public: bool IsFixedLayout();
/**
* Returns true if a view is standalone.
*
* @since 3.0
*/
public: bool IsStandaloneView(IViewReference::Pointer ref);
/**
* Returns whether the title for a view should
* be shown. This applies only to standalone views.
*
* @since 3.0
*/
public: bool GetShowTitleView(IViewReference::Pointer ref);
/**
* Creates a new presentation from a persistence file.
* Note: This method should not modify the current state of the perspective.
*/
private: void LoadCustomPersp(PerspectiveDescriptor::Pointer persp);
private: void UnableToOpenPerspective(PerspectiveDescriptor::Pointer persp,
const QString& status);
/**
* Create a presentation for a perspective.
* Note: This method should not modify the current state of the perspective.
*/
protected: void LoadPredefinedPersp(PerspectiveDescriptor::Pointer persp);
// private: void RemoveAlwaysOn(IActionSetDescriptor::Pointer descriptor) {
// if (descriptor == null) {
// return;
// }
// if (!alwaysOnActionSets.contains(descriptor)) {
// return;
// }
//
// alwaysOnActionSets.remove(descriptor);
// if (page != null) {
// page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_HIDE);
// }
// }
// protected: void AddAlwaysOff(IActionSetDescriptor descriptor) {
// if (descriptor == null) {
// return;
// }
// if (alwaysOffActionSets.contains(descriptor)) {
// return;
// }
// alwaysOffActionSets.add(descriptor);
// if (page != null) {
// page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_MASK);
// }
// removeAlwaysOn(descriptor);
// }
// protected: void AddAlwaysOn(IActionSetDescriptor descriptor) {
// if (descriptor == null) {
// return;
// }
// if (alwaysOnActionSets.contains(descriptor)) {
// return;
// }
// alwaysOnActionSets.add(descriptor);
// if (page != null) {
// page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_SHOW);
// }
// removeAlwaysOff(descriptor);
// }
// private: void RemoveAlwaysOff(IActionSetDescriptor descriptor) {
// if (descriptor == null) {
// return;
// }
// if (!alwaysOffActionSets.contains(descriptor)) {
// return;
// }
// alwaysOffActionSets.remove(descriptor);
// if (page != null) {
// page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_UNMASK);
// }
// }
/**
* activate.
*/
protected: void OnActivate();
private:
/**
* An 'orphan' perspective is one that was originally created through a
* contribution but whose contributing bundle is no longer available. In
* order to allow it to behave correctly within the environment (for Close,
* Reset...) we turn it into a 'custom' perspective on its first activation.
*/
void FixOrphan();
/**
* deactivate.
*/
protected: void OnDeactivate();
/**
* Notifies that a part has been activated.
*/
public: void PartActivated(IWorkbenchPart::Pointer activePart);
/**
* The user successfully performed a Show In... action on the specified part.
* Update the history.
*/
public: void PerformedShowIn(const QString& partId);
/**
* Fills a presentation with layout data.
* Note: This method should not modify the current state of the perspective.
*/
public: bool RestoreState(IMemento::Pointer memento);
bool CreateReferences(const QList& views);
/**
* Fills a presentation with layout data.
* Note: This method should not modify the current state of the perspective.
*/
public: bool RestoreState();
/**
* Returns the ActionSets read from perspectiveExtensions in the registry.
*/
// protected: ArrayList GetPerspectiveExtensionActionSets() {
// PerspectiveExtensionReader reader = new PerspectiveExtensionReader();
// reader
// .setIncludeOnlyTags(new String[] { IWorkbenchRegistryConstants.TAG_ACTION_SET });
// PageLayout layout = new PageLayout();
// reader.extendLayout(null, descriptor.getOriginalId(), layout);
// return layout.getActionSets();
// }
/**
* Returns the Show In... part ids read from the registry.
*/
protected: QList GetShowInIdsFromRegistry();
/**
* Save the layout.
*/
public: void SaveDesc();
/**
* Save the layout.
*/
public: void SaveDescAs(IPerspectiveDescriptor::Pointer desc);
/**
* Save the layout.
*/
public: bool SaveState(IMemento::Pointer memento);
/**
* Save the layout.
*/
private: bool SaveState(IMemento::Pointer memento, PerspectiveDescriptor::Pointer p,
bool saveInnerViewState);
// public: void turnOnActionSets(IActionSetDescriptor[] newArray) {
// for (int i = 0; i < newArray.length; i++) {
// IActionSetDescriptor descriptor = newArray[i];
//
// addAlwaysOn(descriptor);
// }
// }
// public: void turnOffActionSets(IActionSetDescriptor[] toDisable) {
// for (int i = 0; i < toDisable.length; i++) {
// IActionSetDescriptor descriptor = toDisable[i];
//
// turnOffActionSet(descriptor);
// }
// }
// public: void turnOffActionSet(IActionSetDescriptor toDisable) {
// addAlwaysOff(toDisable);
// }
/**
* Sets the perspective actions for this page.
* This is List of Strings.
*/
public: void SetPerspectiveActionIds(const QList& list);
/**
* Sets the ids of the parts to list in the Show In... prompter.
* This is a List of Strings.
*/
public: void SetShowInPartIds(const QList& list);
/**
* Sets the ids of the views to list in the Show View shortcuts.
* This is a List of Strings.
*/
public: void SetShowViewActionIds(const QList& list);
/**
* Show the editor area if not visible
*/
protected: void ShowEditorArea();
/**
* Show the editor area if not visible
*/
protected: void ShowEditorAreaLocal();
public: void SetEditorAreaState(int newState);
public: int GetEditorAreaState();
/**
*
*/
public: void RefreshEditorAreaVisibility();
/**
* Resolves a view's id into its reference, creating the
* view if necessary.
*
* @param viewId The primary id of the view (must not be
* null
* @param secondaryId The secondary id of a multiple-instance view
* (may be null
).
*
* @return The reference to the specified view. This may be null if the
* view fails to create (i.e. thrown a PartInitException)
*/
public: IViewReference::Pointer GetViewReference(const QString& viewId, const QString& secondaryId);
/**
* Shows the view with the given id and secondary id.
*/
public: IViewPart::Pointer ShowView(const QString& viewId, const QString& secondaryId);
/**
* Returns the old part reference.
* Returns null if there was no previously active part.
*
* @return the old part reference or null
*/
public: IWorkbenchPartReference::Pointer GetOldPartRef();
/**
* Sets the old part reference.
*
* @param oldPartRef The old part reference to set, or null
*/
public: void SetOldPartRef(IWorkbenchPartReference::Pointer oldPartRef);
// //for dynamic UI
// protected: void AddActionSet(IActionSetDescriptor newDesc) {
// IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
// try {
// service.activateContext(ContextAuthority.DEFER_EVENTS);
// for (int i = 0; i < alwaysOnActionSets.size(); i++) {
// IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOnActionSets
// .get(i);
// if (desc.getId().equals(newDesc.getId())) {
// removeAlwaysOn(desc);
// removeAlwaysOff(desc);
// break;
// }
// }
// addAlwaysOn(newDesc);
// } finally {
// service.activateContext(ContextAuthority.SEND_EVENTS);
// }
// }
// // for dynamic UI
// /* package */void removeActionSet(String id) {
// IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class);
// try {
// service.activateContext(ContextAuthority.DEFER_EVENTS);
// for (int i = 0; i < alwaysOnActionSets.size(); i++) {
// IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOnActionSets
// .get(i);
// if (desc.getId().equals(id)) {
// removeAlwaysOn(desc);
// break;
// }
// }
//
// for (int i = 0; i < alwaysOffActionSets.size(); i++) {
// IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOffActionSets
// .get(i);
// if (desc.getId().equals(id)) {
// removeAlwaysOff(desc);
// break;
// }
// }
// } finally {
// service.activateContext(ContextAuthority.SEND_EVENTS);
// }
// }
// void removeActionSet(IActionSetDescriptor toRemove) {
// removeAlwaysOn(toRemove);
// removeAlwaysOff(toRemove);
// }
/**
* Returns whether the given view is closeable in this perspective.
*
* @since 3.0
*/
public: bool IsCloseable(IViewReference::Pointer reference);
/**
* Returns whether the given view is moveable in this perspective.
*
* @since 3.0
*/
public: bool IsMoveable(IViewReference::Pointer reference);
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
*
* This is only intended for use by test suites.
*
*
* @param buf
*/
public: void DescribeLayout(QString& buf) const;
/**
* Sanity-checks the LayoutParts in this perspective. Throws an Assertation exception
* if an object's internal state is invalid.
*/
public: void TestInvariants();
// public: IActionSetDescriptor[] getAlwaysOnActionSets() {
// return (IActionSetDescriptor[]) alwaysOnActionSets.toArray(new IActionSetDescriptor[alwaysOnActionSets.size()]);
// }
// public: IActionSetDescriptor[] getAlwaysOffActionSets() {
// return (IActionSetDescriptor[]) alwaysOffActionSets.toArray(new IActionSetDescriptor[alwaysOffActionSets.size()]);
// }
/**
* Used to restrict the use of the new min/max behavior to envoronments
* in which it has a chance of working...
*
* @param activePerspective We pass this in as an arg so others won't have
* to check it for 'null' (which is one of the failure cases)
*
*/
public: static bool UseNewMinMax(Perspective::Pointer activePerspective);
};
}
#endif /*BERRYPERSPECTIVE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.cpp
index faecdba123..9659589fd5 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.cpp
@@ -1,335 +1,331 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPerspectiveDescriptor.h"
#include "berryWorkbenchRegistryConstants.h"
#include "berryWorkbenchPlugin.h"
#include "berryWorkbenchConstants.h"
#include "berryPerspectiveRegistry.h"
#include "berryStatus.h"
#include "berryIContributor.h"
namespace berry
{
PerspectiveDescriptor::PerspectiveDescriptor(const QString& id,
const QString& label, PerspectiveDescriptor::Pointer originalDescriptor)
: singleton(false), fixed(false)
{
this->id = id;
this->label = label;
if (originalDescriptor != 0)
{
this->originalId = originalDescriptor->GetOriginalId();
this->imageDescriptor = originalDescriptor->imageDescriptor;
// This perspective is based on a perspective in some bundle -- if
// that
// bundle goes away then I think it makes sense to treat this
// perspective
// the same as any other -- so store it with the original
// descriptor's
// bundle's list.
//
// It might also make sense the other way...removing the following
// line
// will allow the perspective to stay around when the originating
// bundle
// is unloaded.
//
// This might also have an impact on upgrade cases -- should we
// really be
// destroying all user customized perspectives when the older
// version is
// removed?
//
// I'm leaving this here for now since its a good example, but
// wouldn't be
// surprised if we ultimately decide on the opposite.
//
// The reason this line is important is that this is the value used
// to
// put the object into the UI level registry. When that bundle goes
// away,
// the registry will remove the entire list of objects. So if this
// desc
// has been put into that list -- it will go away.
this->pluginId = originalDescriptor->GetPluginId();
}
}
PerspectiveDescriptor::PerspectiveDescriptor(const QString& id,
IConfigurationElement::Pointer configElement)
: singleton(false), fixed(false)
{
this->configElement = configElement;
this->id = id;
// Sanity check.
if ((this->GetId() == "") || (this->GetLabel() == "")
|| (this->GetFactoryClassName() == ""))
{
IStatus::Pointer status(new Status(
IStatus::ERROR_TYPE,
PlatformUI::PLUGIN_ID(),
0,
QString("Invalid extension (missing label, id or class name): ") + GetId()));
throw CoreException(status);
}
}
IPerspectiveFactory::Pointer PerspectiveDescriptor::CreateFactory()
{
// if there is an originalId, then use that descriptor instead
if (originalId != "")
{
// Get the original descriptor to create the factory. If the
// original is gone then nothing can be done.
IPerspectiveDescriptor::Pointer
target =
dynamic_cast (WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()) ->FindPerspectiveWithId(
originalId);
return target == 0 ? IPerspectiveFactory::Pointer(0) : target.Cast<
PerspectiveDescriptor> ()->CreateFactory();
}
// otherwise try to create the executable extension
if (configElement != 0)
{
try
{
IPerspectiveFactory::Pointer factory(
configElement ->CreateExecutableExtension (
WorkbenchRegistryConstants::ATT_CLASS));
return factory;
}
catch (const CoreException& /*e*/)
{
// do nothing
}
}
return IPerspectiveFactory::Pointer(0);
}
void PerspectiveDescriptor::DeleteCustomDefinition()
{
dynamic_cast (WorkbenchPlugin::GetDefault() ->GetPerspectiveRegistry())->DeleteCustomDefinition(
PerspectiveDescriptor::Pointer(this));
}
QString PerspectiveDescriptor::GetDescription() const
{
return configElement == 0 ? description : RegistryReader::GetDescription(
configElement);
}
+void PerspectiveDescriptor::SetDescription(const QString& desc)
+{
+ description = desc;
+}
+
bool PerspectiveDescriptor::GetFixed() const
{
if (configElement == 0)
return fixed;
return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_FIXED).compare("true", Qt::CaseInsensitive) == 0;
}
-std::vector< std::string> PerspectiveDescriptor::GetKeywordReferences() const
+QStringList PerspectiveDescriptor::GetKeywordReferences() const
{
- std::vector result;
+ QStringList result;
if (configElement.IsNull())
{
return result;
}
- std::string keywordRefId;
- std::vector keywordRefs;
- berry::IConfigurationElement::vector::iterator keywordRefsIt;
- keywordRefs = configElement->GetChildren("keywordReference");
- for (keywordRefsIt = keywordRefs.begin()
- ; keywordRefsIt != keywordRefs.end(); ++keywordRefsIt) // iterate over all refs
+ auto keywordRefs = configElement->GetChildren("keywordReference");
+ for (auto keywordRefsIt = keywordRefs.begin();
+ keywordRefsIt != keywordRefs.end(); ++keywordRefsIt) // iterate over all refs
{
- (*keywordRefsIt)->GetAttribute("id", keywordRefId);
- result.push_back(keywordRefId);
+ result.push_back((*keywordRefsIt)->GetAttribute("id"));
}
return result;
}
QString PerspectiveDescriptor::GetId() const
{
return id;
}
QString PerspectiveDescriptor::GetPluginId() const
{
return configElement == 0 ? pluginId : configElement->GetContributor()->GetName();
}
ImageDescriptor::Pointer PerspectiveDescriptor::GetImageDescriptor() const
{
if (imageDescriptor)
return imageDescriptor;
if (configElement)
{
QString icon = configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ICON);
if (!icon.isEmpty())
{
imageDescriptor = AbstractUICTKPlugin::ImageDescriptorFromPlugin(
configElement->GetContributor()->GetName(), icon);
}
}
if (!imageDescriptor)
{
imageDescriptor = ImageDescriptor::GetMissingImageDescriptor();
}
return imageDescriptor;
}
-std::vector PerspectiveDescriptor::GetCategoryPath()
+QStringList PerspectiveDescriptor::GetCategoryPath() const
{
- std::string category;
- categoryPath.clear();
+ if(!categoryPath.empty()) return categoryPath;
- if (configElement.IsNotNull() && configElement->GetAttribute(WorkbenchRegistryConstants::TAG_CATEGORY, category))
+ if (configElement.IsNotNull())
{
- Poco::StringTokenizer stok(category, "/", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
- // Parse the path tokens and store them
- for (Poco::StringTokenizer::Iterator iter = stok.begin(); iter != stok.end(); ++iter)
- {
- categoryPath.push_back(*iter);
- }
+ QString category = configElement->GetAttribute(WorkbenchRegistryConstants::TAG_CATEGORY);
+ categoryPath = category.split('/', QString::SkipEmptyParts);
}
return categoryPath;
}
QString PerspectiveDescriptor::GetLabel() const
{
if (configElement == 0)
return label;
return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME);
}
QString PerspectiveDescriptor::GetOriginalId() const
{
if (originalId == "")
{
return this->GetId();
}
return originalId;
}
bool PerspectiveDescriptor::HasCustomDefinition() const
{
return dynamic_cast (WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry())->HasCustomDefinition(
PerspectiveDescriptor::ConstPointer(this));
}
bool PerspectiveDescriptor::HasDefaultFlag() const
{
if (configElement == 0)
{
return false;
}
return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_DEFAULT).compare("true", Qt::CaseInsensitive) == 0;
}
bool PerspectiveDescriptor::IsPredefined() const
{
return this->GetFactoryClassName() != "" && configElement != 0;
}
bool PerspectiveDescriptor::IsSingleton() const
{
if (configElement == 0)
return singleton;
return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_SINGLETON).compare("true", Qt::CaseInsensitive) == 0;
}
bool PerspectiveDescriptor::RestoreState(IMemento::Pointer memento)
{
IMemento::Pointer childMem(memento->GetChild(
WorkbenchConstants::TAG_DESCRIPTOR));
if (childMem)
{
childMem->GetString(WorkbenchConstants::TAG_ID, id);
childMem->GetString(WorkbenchConstants::TAG_DESCRIPTOR, originalId);
childMem->GetString(WorkbenchConstants::TAG_LABEL, label);
childMem->GetString(WorkbenchConstants::TAG_CLASS, className);
int singletonVal;
singleton = childMem->GetInteger(WorkbenchConstants::TAG_SINGLETON,
singletonVal);
// Find a descriptor in the registry.
IPerspectiveDescriptor::Pointer
descriptor =
WorkbenchPlugin::GetDefault() ->GetPerspectiveRegistry()->FindPerspectiveWithId(
this->GetOriginalId());
if (descriptor)
{
// Copy the state from the registred descriptor.
imageDescriptor = descriptor->GetImageDescriptor();
}
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
return true;
}
void PerspectiveDescriptor::RevertToPredefined()
{
if (this->IsPredefined())
{
this->DeleteCustomDefinition();
}
}
bool PerspectiveDescriptor::SaveState(IMemento::Pointer memento)
{
IMemento::Pointer childMem(memento->CreateChild(
WorkbenchConstants::TAG_DESCRIPTOR));
childMem->PutString(WorkbenchConstants::TAG_ID, GetId());
if (!originalId.isEmpty())
{
childMem->PutString(WorkbenchConstants::TAG_DESCRIPTOR, originalId);
}
childMem->PutString(WorkbenchConstants::TAG_LABEL, GetLabel());
childMem->PutString(WorkbenchConstants::TAG_CLASS, GetFactoryClassName());
if (singleton)
{
childMem->PutInteger(WorkbenchConstants::TAG_SINGLETON, 1);
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null);
return true;
}
IConfigurationElement::Pointer PerspectiveDescriptor::GetConfigElement() const
{
return configElement;
}
QString PerspectiveDescriptor::GetFactoryClassName() const
{
return configElement == 0 ? className : RegistryReader::GetClassValue(
configElement, WorkbenchRegistryConstants::ATT_CLASS);
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.h
index 0b0cd0ada6..33e52434b2 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveDescriptor.h
@@ -1,244 +1,245 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYPERSPECTIVEDESCRIPTOR_H_
#define BERRYPERSPECTIVEDESCRIPTOR_H_
#include
#include "berryIPerspectiveDescriptor.h"
#include "berryIPerspectiveFactory.h"
#include "berryIMemento.h"
+#include
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* PerspectiveDescriptor.
*
* A PerspectiveDesciptor has 3 states:
*
*
* - It
isPredefined()
, in which case it was defined from an
* extension point.
* - It
isPredefined()
and hasCustomFile
, in
* which case the user has customized a predefined perspective.
* - It
hasCustomFile
, in which case the user created a new
* perspective.
*
*
*/
class PerspectiveDescriptor : public IPerspectiveDescriptor {
public:
berryObjectMacro(PerspectiveDescriptor);
private:
QString id;
QString pluginId;
QString originalId;
QString label;
QString className;
QString description;
bool singleton;
bool fixed;
mutable ImageDescriptor::Pointer imageDescriptor;
IConfigurationElement::Pointer configElement;
- std::vector categoryPath;
+ mutable QStringList categoryPath;
/**
* Create a new empty descriptor.
*
* @param id
* the id of the new descriptor
* @param label
* the label of the new descriptor
* @param originalDescriptor
* the descriptor that this descriptor is based on
*/
public: PerspectiveDescriptor(const QString& id, const QString& label,
PerspectiveDescriptor::Pointer originalDescriptor);
/**
* Create a descriptor from a config element.
*
* @param id
* the id of the element to create
* @param configElement
* the element to base this perspective on
* @throws CoreException
* thrown if there are any missing attributes
*/
public: PerspectiveDescriptor(const QString& id, IConfigurationElement::Pointer configElement);
/**
* Creates a factory for a predefined perspective. If the perspective is not
* predefined return null
.
*
* @return the IPerspectiveFactory or null
* @throws CoreException
* if the object could not be instantiated.
*/
public: IPerspectiveFactory::Pointer CreateFactory();
/**
* Deletes the custom definition for a perspective..
*/
public: void DeleteCustomDefinition();
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getDescription()
*/
public: QString GetDescription() const;
- public: void SetDescription(std::string desc) {description = desc; }
+ public: void SetDescription(const QString& desc);
- std::vector GetKeywordReferences() const;
+ QStringList GetKeywordReferences() const;
/**
* Returns whether or not this perspective is fixed.
*
* @return whether or not this perspective is fixed
*/
public: bool GetFixed() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getId()
*/
public: QString GetId() const;
public: QString GetPluginId() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getImageDescriptor()
*/
public: ImageDescriptor::Pointer GetImageDescriptor() const;
/*
* (non-Javadoc)
*
* @see org.blueberry.ui.IPerspectiveDescriptor#getLabel()
*/
public: QString GetLabel() const;
/**
* Return the original id of this descriptor.
*
* @return the original id of this descriptor
*/
public: QString GetOriginalId() const;
/**
* Returns true
if this perspective has a custom definition.
*
* @return whether this perspective has a custom definition
*/
public: bool HasCustomDefinition() const;
/**
* Returns true
if this perspective wants to be default.
*
* @return whether this perspective wants to be default
*/
public: bool HasDefaultFlag() const;
/**
* Returns true
if this perspective is predefined by an
* extension.
*
* @return boolean whether this perspective is predefined by an extension
*/
public: bool IsPredefined() const;
/**
* Returns true
if this perspective is a singleton.
*
* @return whether this perspective is a singleton
*/
public: bool IsSingleton() const;
/**
* Restore the state of a perspective from a memento.
*
* @param memento
* the memento to restore from
* @return the IStatus
of the operation
* @see org.blueberry.ui.IPersistableElement
*/
public: bool RestoreState(IMemento::Pointer memento);
/**
* Revert to the predefined extension template. Does nothing if this
* descriptor is user defined.
*/
public: void RevertToPredefined();
/**
* Save the state of a perspective to a memento.
*
* @param memento
* the memento to restore from
* @return the IStatus
of the operation
* @see org.blueberry.ui.IPersistableElement
*/
public: bool SaveState(IMemento::Pointer memento);
/**
* Return the configuration element used to create this perspective, if one
* was used.
*
* @return the configuration element used to create this perspective
* @since 3.0
*/
public: IConfigurationElement::Pointer GetConfigElement() const;
/**
* Returns the factory class name for this descriptor.
*
* @return the factory class name for this descriptor
* @since 3.1
*/
public: QString GetFactoryClassName() const;
/**
* Return the category path of this descriptor
*
* @return the category path of this descriptor
*/
- public: std::vector GetCategoryPath();
+ public: QStringList GetCategoryPath() const;
};
}
#endif /*BERRYPERSPECTIVEDESCRIPTOR_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveHelper.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveHelper.cpp
index 6047ab95a3..d3f696e88a 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveHelper.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveHelper.cpp
@@ -1,1492 +1,1492 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryPerspectiveHelper.h"
#include "berryLayoutTree.h"
#include "berryEditorSashContainer.h"
#include "berryDragUtil.h"
#include "berryPresentationFactoryUtil.h"
#include "berryWorkbenchConstants.h"
#include
namespace berry
{
const int PerspectiveHelper::MIN_DETACH_WIDTH = 150;
const int PerspectiveHelper::MIN_DETACH_HEIGHT = 250;
PerspectiveHelper::DragOverListener::DragOverListener(PerspectiveHelper* perspHelper) :
perspHelper(perspHelper)
{
}
IDropTarget::Pointer PerspectiveHelper::DragOverListener::Drag(
void* /*currentControl*/, const Object::Pointer& draggedObject, const Point& /*position*/,
const Rectangle& dragRectangle)
{
if (draggedObject.Cast() != 0)
{
PartPane::Pointer part = draggedObject.Cast();
if (part->GetContainer().Cast()->GetAppearance() == PresentationFactoryUtil::ROLE_EDITOR)
return IDropTarget::Pointer(0);
// Views that haven't been shown yet have no 'control' which causes
// 'GetWorkbenchWindow' to return 'null' so check explicitly
if (part->GetPage() != perspHelper->page)
return IDropTarget::Pointer(0);
else if (part->GetWorkbenchWindow() != perspHelper->page->GetWorkbenchWindow())
return IDropTarget::Pointer(0);
if (perspHelper->dropTarget == 0)
perspHelper->dropTarget = new ActualDropTarget(perspHelper, part, dragRectangle);
else
perspHelper->dropTarget->SetTarget(part, dragRectangle);
}
else if (draggedObject.Cast() != 0)
{
PartStack::Pointer stack = draggedObject.Cast();
if (stack->GetAppearance() == PresentationFactoryUtil::ROLE_EDITOR)
return IDropTarget::Pointer(0);
if (stack->GetWorkbenchWindow() != perspHelper->page->GetWorkbenchWindow())
return IDropTarget::Pointer(0);
if (perspHelper->dropTarget == 0)
perspHelper->dropTarget = new ActualDropTarget(perspHelper, stack, dragRectangle);
else
perspHelper->dropTarget->SetTarget(stack, dragRectangle);
}
return perspHelper->dropTarget;
}
void PerspectiveHelper::ActualDropTarget::SetTarget(PartPane::Pointer part,
const Rectangle& dragRectangle)
{
this->stack = 0;
this->part = part;
this->dragRectangle = dragRectangle;
}
void PerspectiveHelper::ActualDropTarget::SetTarget(PartStack::Pointer stack,
const Rectangle& dragRectangle)
{
this->stack = stack;
this->part = 0;
this->dragRectangle = dragRectangle;
}
PerspectiveHelper::ActualDropTarget::ActualDropTarget(PerspectiveHelper* perspHelper, PartPane::Pointer part,
const Rectangle& dragRectangle)
: AbstractDropTarget(), perspHelper(perspHelper)
{
this->SetTarget(part, dragRectangle);
}
PerspectiveHelper::ActualDropTarget::ActualDropTarget(PerspectiveHelper* perspHelper, PartStack::Pointer stack,
const Rectangle& dragRectangle)
: AbstractDropTarget(), perspHelper(perspHelper)
{
this->SetTarget(stack, dragRectangle);
}
void PerspectiveHelper::ActualDropTarget::Drop()
{
if (part != 0)
{
Shell::Pointer shell = part->GetShell();
if (shell->GetData().Cast () != 0)
{
// if only one view in tab folder then do a window move
ILayoutContainer::Pointer container = part->GetContainer();
if (container.Cast () != 0)
{
if (container.Cast()->GetItemCount() == 1)
{
shell->SetLocation(dragRectangle.x, dragRectangle.y);
return;
}
}
}
// // If layout is modified always zoom out.
// if (isZoomed())
// {
// zoomOut();
// }
// do a normal part detach
perspHelper->DetachPart(part, dragRectangle.x, dragRectangle.y);
}
else if (stack != 0)
{
Shell::Pointer shell = stack->GetShell();
if (shell->GetData().Cast () != 0)
{
// only one tab folder in a detach window, so do window
// move
shell->SetLocation(dragRectangle.x, dragRectangle.y);
return;
}
// // If layout is modified always zoom out.
// if (isZoomed())
// {
// zoomOut();
// }
// do a normal part detach
perspHelper->Detach(stack, dragRectangle.x, dragRectangle.y);
}
}
DnDTweaklet::CursorType PerspectiveHelper::ActualDropTarget::GetCursor()
{
return DnDTweaklet::CURSOR_OFFSCREEN;
}
PerspectiveHelper::MatchingPart::MatchingPart(const QString& pid,
const QString& sid, LayoutPart::Pointer part)
{
this->pid = pid;
this->sid = sid;
this->part = part;
this->len = pid.size() + sid.size();
this->hasWildcard = (pid.indexOf(PartPlaceholder::WILD_CARD) != -1) ||
(sid.indexOf(PartPlaceholder::WILD_CARD) != -1);
}
bool PerspectiveHelper::CompareMatchingParts::operator()(const MatchingPart& m1, const MatchingPart& m2) const
{
// specific ids always outweigh ids with wildcards
if (m1.hasWildcard && !m2.hasWildcard)
{
return true;
}
if (!m1.hasWildcard && m2.hasWildcard)
{
return false;
}
// if both are specific or both have wildcards, simply compare based on length
return m1.len > m2.len;
}
PerspectiveHelper::PerspectiveHelper(WorkbenchPage* workbenchPage,
ViewSashContainer::Pointer mainLayout, Perspective* persp)
: page(workbenchPage), perspective(persp),
mainLayout(mainLayout),
detachable(false), active(false)
{
// Views can be detached if the feature is enabled (true by default,
// use the plug-in customization file to disable), and if the platform
// supports detaching.
this->dragTarget.reset(new DragOverListener(this));
//TODO preference store
// IPreferenceStore store = PlatformUI.getPreferenceStore();
// this.detachable = store.getBoolean(
// IWorkbenchPreferenceConstants.ENABLE_DETACHED_VIEWS);
this->detachable = true;
if (this->detachable)
{
// Check if some arbitrary Composite supports reparenting. If it
// doesn't, views cannot be detached.
void* client = workbenchPage->GetClientComposite();
if (client == 0)
{
// The workbench page is not initialized. I don't think this can happen,
// but if it does, silently set detachable to false.
this->detachable = false;
}
else
{
this->detachable = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->IsReparentable(client);
}
}
}
void PerspectiveHelper::Activate(void* parent)
{
if (active)
{
return;
}
parentWidget = parent;
// Activate main layout
// make sure all the views have been properly parented
QList children;
this->CollectViewPanes(children, mainLayout->GetChildren());
for (QList::iterator iter = children.begin();
iter != children.end(); ++iter)
{
PartPane::Pointer part = *iter;
part->Reparent(parent);
}
mainLayout->CreateControl(parent);
mainLayout->SetActive(true);
// Open the detached windows.
for (DetachedWindowsType::iterator iter = detachedWindowList.begin();
iter != detachedWindowList.end(); ++iter)
{
(*iter)->Open();
}
this->EnableAllDrag();
// // Ensure that the maximized stack's presentation state is correct
// if (maximizedStackId != 0)
// {
// LayoutPart part = this->FindPart(maximizedStackId);
// if (part.Cast() != 0)
// {
// maximizedStack = (PartStack) part;
// maximizedStackId = 0;
// }
// }
//
// // NOTE: we only handle ViewStacks here; Editor Stacks are handled by the
// // perspective
// if (maximizedStack instanceof ViewStack)
// {
// maximizedStack.setPresentationState(IStackPresentationSite.STATE_MAXIMIZED);
// }
active = true;
}
void PerspectiveHelper::AddPart(LayoutPart::Pointer part)
{
// Look for a placeholder.
PartPlaceholder::Pointer placeholder;
LayoutPart::Pointer testPart;
QString primaryId = part->GetID();
QString secondaryId;
IViewReference::Pointer ref;
if (part.Cast () != 0)
{
PartPane::Pointer pane = part.Cast ();
ref = pane->GetPartReference().Cast ();
if (ref != 0)
secondaryId = ref->GetSecondaryId();
}
if (secondaryId != "")
{
testPart = this->FindPart(primaryId, secondaryId);
}
else
{
testPart = this->FindPart(primaryId);
}
// validate the testPart
if (testPart != 0 && testPart.Cast() != 0)
{
placeholder = testPart.Cast ();
}
// If there is no placeholder do a simple add. Otherwise, replace the
// placeholder if its not a pattern matching placholder
if (placeholder == 0)
{
part->Reparent(mainLayout->GetParent());
LayoutPart::Pointer relative = mainLayout->FindBottomRight();
if (relative != 0 && relative.Cast() != 0)
{
ILayoutContainer::Pointer stack =
relative.Cast ();
if (stack->AllowsAdd(part))
{
mainLayout->Stack(part, stack);
}
else
{
mainLayout->AddPart(part);
}
}
else
{
mainLayout->AddPart(part);
}
}
else
{
ILayoutContainer::Pointer container = placeholder->GetContainer();
if (container != 0)
{
if (container.Cast () != 0)
{
//Create a detached window add the part on it.
DetachedPlaceHolder::Pointer holder = container.Cast();
detachedPlaceHolderList.removeAll(holder);
container->Remove(testPart);
DetachedWindow::Pointer window(new DetachedWindow(page));
detachedWindowList.push_back(window);
window->Create();
part->CreateControl(window->GetShell()->GetControl());
// Open window.
window->GetShell()->SetBounds(holder->GetBounds());
window->Open();
// add part to detached window.
PartPane::Pointer pane = part.Cast();
window->Add(pane);
QList otherChildren = holder->GetChildren();
for (QList::iterator iter = otherChildren.begin();
iter != otherChildren.end(); ++iter)
{
part->GetContainer()->Add(*iter);
}
}
else
{
// show parent if necessary
if (container.Cast () != 0)
{
ContainerPlaceholder::Pointer containerPlaceholder =
container.Cast();
ILayoutContainer::Pointer parentContainer =
containerPlaceholder->GetContainer();
if (parentContainer == 0) return;
container = containerPlaceholder->GetRealContainer().Cast();
if (container.Cast () != 0)
{
parentContainer->Replace(containerPlaceholder,
container.Cast());
}
containerPlaceholder->SetRealContainer(ILayoutContainer::Pointer(0));
}
// // reparent part.
// if (container.Cast() == 0)
// {
// // We don't need to reparent children of PartTabFolders since they will automatically
// // reparent their children when they become visible. This if statement used to be
// // part of an else branch. Investigate if it is still necessary.
// part->Reparent(mainLayout->GetParent());
// }
// see if we should replace the placeholder
if (placeholder->HasWildCard())
{
if (PartSashContainer::Pointer sashContainer = container.Cast())
{
sashContainer->AddChildForPlaceholder(part, placeholder);
}
else
{
container->Add(part);
}
}
else
{
container->Replace(placeholder, part);
}
}
}
}
}
void PerspectiveHelper::AttachPart(IViewReference::Pointer ref)
{
PartPane::Pointer pane = ref.Cast()->GetPane();
// Restore any maximized part before re-attaching.
// Note that 'getMaximizedStack != 0' implies 'useNewMinMax'
// if (getMaximizedStack() != 0)
// {
// getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED);
// }
this->DerefPart(pane);
this->AddPart(pane);
this->BringPartToTop(pane);
pane->SetFocus();
}
bool PerspectiveHelper::CanDetach()
{
return detachable;
}
bool PerspectiveHelper::BringPartToTop(LayoutPart::Pointer part)
{
ILayoutContainer::Pointer container = part->GetContainer();
if (container != 0 && container.Cast () != 0)
{
PartStack::Pointer folder = container.Cast ();
if (folder->GetSelection() != part)
{
folder->SetSelection(part);
return true;
}
}
return false;
}
bool PerspectiveHelper::IsPartVisible(IWorkbenchPartReference::Pointer partRef)
{
LayoutPart::Pointer foundPart;
if (partRef.Cast () != 0)
{
foundPart = this->FindPart(partRef->GetId(),
partRef.Cast()->GetSecondaryId());
}
else
{
foundPart = this->FindPart(partRef->GetId());
}
if (foundPart == 0)
{
return false;
}
if (foundPart.Cast () != 0)
{
return false;
}
ILayoutContainer::Pointer container = foundPart->GetContainer();
if (container.Cast () != 0)
{
return false;
}
if (container.Cast () != 0)
{
PartStack::Pointer folder = container.Cast();
LayoutPart::Pointer visiblePart = folder->GetSelection();
if (visiblePart == 0)
{
return false;
}
return partRef == visiblePart.Cast()->GetPartReference();
}
return true;
}
bool PerspectiveHelper::WillPartBeVisible(const QString& partId)
{
return this->WillPartBeVisible(partId, 0);
}
bool PerspectiveHelper::WillPartBeVisible(const QString& partId,
const QString& secondaryId)
{
LayoutPart::Pointer part = this->FindPart(partId, secondaryId);
if (part == 0)
{
return false;
}
ILayoutContainer::Pointer container = part->GetContainer();
if (container != 0 && container.Cast () != 0)
{
container = container.Cast()->GetRealContainer().Cast();
}
if (container != 0 && container.Cast () != 0)
{
PartStack::Pointer folder = container.Cast();
if (folder->GetSelection() == 0)
{
return false;
}
return part->GetID() == folder->GetSelection()->GetID();
}
return true;
}
QList PerspectiveHelper::CollectPlaceholders()
{
// Scan the main window.
QList results = this->CollectPlaceholders(
mainLayout->GetChildren());
// Scan each detached window.
if (detachable)
{
for (DetachedWindowsType::iterator winIter = detachedWindowList.begin();
winIter != detachedWindowList.end(); ++winIter)
{
DetachedWindow::Pointer win = *winIter;
QList moreResults = win->GetChildren();
if (moreResults.size()> 0)
{
for (QList::iterator iter = moreResults.begin();
iter != moreResults.end(); ++iter)
{
if (iter->Cast() != 0)
results.push_back(iter->Cast());
}
}
}
}
return results;
}
QList PerspectiveHelper::CollectPlaceholders(
const QList& parts)
{
QList result;
for (QList::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (ILayoutContainer::Pointer container = part.Cast())
{
// iterate through sub containers to find sub-parts
QList newParts = this->CollectPlaceholders(
container->GetChildren());
result.append(newParts);
}
else if (PartPlaceholder::Pointer placeholder = part.Cast())
{
result.push_back(placeholder);
}
}
return result;
}
void PerspectiveHelper::CollectViewPanes(QList& result)
{
// Scan the main window.
this->CollectViewPanes(result, mainLayout->GetChildren());
// Scan each detached window.
if (detachable)
{
for (DetachedWindowsType::iterator winIter = detachedWindowList.begin();
winIter != detachedWindowList.end(); ++winIter)
{
DetachedWindow::Pointer win = *winIter;
CollectViewPanes(result, win->GetChildren());
}
}
}
void PerspectiveHelper::CollectViewPanes(QList& result,
const QList& parts)
{
for (QList::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (PartPane::Pointer partPane = part.Cast())
{
if(partPane->GetPartReference().Cast())
{
result.push_back(partPane);
}
}
else if (ILayoutContainer::Pointer container = part.Cast ())
{
this->CollectViewPanes(result, container->GetChildren());
}
}
}
void PerspectiveHelper::Deactivate()
{
if (!active)
{
return;
}
this->DisableAllDrag();
// Reparent all views to the main window
void* parent = mainLayout->GetParent();
QList children;
this->CollectViewPanes(children, mainLayout->GetChildren());
for (DetachedWindowsType::iterator winIter = detachedWindowList.begin();
winIter != detachedWindowList.end(); ++winIter)
{
DetachedWindow::Pointer window = *winIter;
CollectViewPanes(children, window->GetChildren());
}
// *** Do we even need to do this if detached windows not supported?
for (QList::iterator itr = children.begin();
itr != children.end(); ++itr)
{
PartPane::Pointer part = *itr;
part->Reparent(parent);
}
// Dispose main layout.
mainLayout->SetActive(false);
// Dispose the detached windows
for (DetachedWindowsType::iterator iter = detachedWindowList.begin();
iter != detachedWindowList.end(); ++iter)
{
(*iter)->Close();
}
active = false;
}
PerspectiveHelper::~PerspectiveHelper()
{
mainLayout->Dispose();
mainLayout->DisposeSashes();
}
void PerspectiveHelper::DescribeLayout(QString& buf) const
{
if (detachable)
{
if (detachedWindowList.size() != 0)
{
buf.append("detachedWindows ("); //$NON-NLS-1$
for (DetachedWindowsType::const_iterator winIter = detachedWindowList.begin();
winIter != detachedWindowList.end(); ++winIter)
{
DetachedWindow::ConstPointer window = *winIter;
QList children = window->GetChildren();
- unsigned int j = 0;
+ int j = 0;
if (children.size() != 0)
{
buf.append("dWindow ("); //$NON-NLS-1$
for (QList::iterator partIter = children.begin();
partIter != children.end(); ++partIter, ++j)
{
if (partIter->Cast() != 0)
buf.append(partIter->Cast()->GetPlaceHolderId());
else if (partIter->Cast() != 0)
buf.append(
partIter->Cast()->GetPartReference()->GetPartName());
if (j < (children.size() - 1))
{
buf.append(", "); //$NON-NLS-1$
}
}
buf.append(")"); //$NON-NLS-1$
}
}
buf.append("), "); //$NON-NLS-1$
}
}
this->GetLayout()->DescribeLayout(buf);
}
void PerspectiveHelper::DerefPart(LayoutPart::Pointer part)
{
// if (part.Cast () != 0)
// {
// IViewReference::Pointer ref = ((ViewPane) part).getViewReference();
// if (perspective.isFastView(ref))
// {
// // Special check: if it's a fast view then it's actual ViewStack
// // may only contain placeholders and the stack is represented in
// // the presentation by a container placeholder...make sure the
// // PartPlaceHolder for 'ref' is removed from the ViewStack
// String id = perspective.getFastViewManager().getIdForRef(ref);
// LayoutPart parentPart = findPart(id, 0);
// if (parentPart.Cast () != 0)
// {
// ViewStack vs =
// (ViewStack) ((ContainerPlaceholder) parentPart).getRealContainer();
// QList kids = vs.getChildren();
// for (int i = 0; i < kids.length; i++)
// {
// if (kids[i].Cast () != 0)
// {
// if (ref.getId().equals(kids[i].id))
// vs.remove(kids[i]);
// }
// }
// }
// perspective.getFastViewManager().removeViewReference(ref, true, true);
// }
// }
// Get vital part stats before reparenting.
ILayoutContainer::Pointer oldContainer = part->GetContainer();
bool wasDocked = part->IsDocked();
Shell::Pointer oldShell = part->GetShell();
// Reparent the part back to the main window
part->Reparent(mainLayout->GetParent());
// Update container.
if (oldContainer == 0)
{
return;
}
oldContainer->Remove(part);
ILayoutContainer::ChildrenType children = oldContainer->GetChildren();
if (wasDocked)
{
bool hasChildren = (children.size()> 0);
if (hasChildren)
{
// make sure one is at least visible
int childVisible = 0;
for (ILayoutContainer::ChildrenType::iterator iter = children.begin();
iter != children.end(); ++iter)
{
if ((*iter)->GetControl() != 0)
{
childVisible++;
}
}
// none visible, then reprarent and remove container
if (oldContainer.Cast () != 0)
{
PartStack::Pointer folder = oldContainer.Cast();
// Is the part in the trim?
bool inTrim = false;
// // Safety check...there may be no FastViewManager
// if (perspective.getFastViewManager() != 0)
// inTrim
// = perspective.getFastViewManager().getFastViews(folder.getID()).size()
// > 0;
if (childVisible == 0 && !inTrim)
{
ILayoutContainer::Pointer parentContainer = folder->GetContainer();
hasChildren = folder->GetChildren().size()> 0;
// We maintain the stack as a place-holder if it has children
// (which at this point would represent view place-holders)
if (hasChildren)
{
folder->Dispose();
// replace the real container with a ContainerPlaceholder
ContainerPlaceholder::Pointer placeholder(
new ContainerPlaceholder(folder->GetID()));
placeholder->SetRealContainer(folder);
parentContainer->Replace(folder, placeholder);
}
}
else if (childVisible == 1)
{
LayoutTree::Pointer layout = mainLayout->GetLayoutTree();
layout = layout->Find(folder);
layout->SetBounds(layout->GetBounds());
}
}
}
if (!hasChildren)
{
// There are no more children in this container, so get rid of
// it
if (oldContainer.Cast () != 0)
{
//BERRY_INFO << "No children left, removing container\n";
LayoutPart::Pointer parent = oldContainer.Cast();
ILayoutContainer::Pointer parentContainer = parent->GetContainer();
if (parentContainer != 0)
{
parentContainer->Remove(parent);
parent->Print(qDebug());
parent->Dispose();
}
}
}
}
else if (!wasDocked)
{
if (children.empty())
{
// There are no more children in this container, so get rid of
// it
// Turn on redraw again just in case it was off.
//oldShell.setRedraw(true);
DetachedWindow::Pointer w = oldShell->GetData().Cast();
oldShell->Close();
detachedWindowList.removeAll(w);
}
else
{
// There are children. If none are visible hide detached
// window.
bool allInvisible = true;
for (ILayoutContainer::ChildrenType::iterator iter = children.begin();
iter != children.end(); ++iter)
{
if (iter->Cast () == 0)
{
allInvisible = false;
break;
}
}
if (allInvisible)
{
DetachedPlaceHolder::Pointer placeholder(new DetachedPlaceHolder("",
oldShell->GetBounds()));
for (ILayoutContainer::ChildrenType::iterator iter = children.begin();
iter != children.end(); ++iter)
{
oldContainer->Remove(*iter);
(*iter)->SetContainer(placeholder);
placeholder->Add(*iter);
}
detachedPlaceHolderList.push_back(placeholder);
DetachedWindow::Pointer w = oldShell->GetData().Cast();
oldShell->Close();
detachedWindowList.removeAll(w);
}
}
}
}
void PerspectiveHelper::Detach(LayoutPart::Pointer part, int x, int y)
{
// Detaching is disabled on some platforms ..
if (!detachable)
{
return;
}
// Calculate detached window size.
Point size = part->GetSize();
if (size.x == 0 || size.y == 0)
{
ILayoutContainer::Pointer container = part->GetContainer();
if (container.Cast () != 0)
{
size = container.Cast()->GetSize();
}
}
int width = std::max(size.x, MIN_DETACH_WIDTH);
int height = std::max(size.y, MIN_DETACH_HEIGHT);
// Create detached window.
DetachedWindow::Pointer window(new DetachedWindow(page));
detachedWindowList.push_back(window);
// Open window.
window->Create();
window->GetShell()->SetBounds(x, y, width, height);
window->Open();
if (part.Cast () != 0)
{
//window.getShell().setRedraw(false);
//parentWidget.setRedraw(false);
PartStack::Pointer stack = part.Cast();
LayoutPart::Pointer visiblePart = stack->GetSelection();
ILayoutContainer::ChildrenType children = stack->GetChildren();
for (ILayoutContainer::ChildrenType::iterator iter = children.begin();
iter != children.end(); ++iter)
{
if (PartPane::Pointer partPane = iter->Cast()
// && check it is a view?
)
{
// remove the part from its current container
this->DerefPart(*iter);
// add part to detached window.
window->Add(*iter);
}
}
if (visiblePart != 0)
{
this->BringPartToTop(visiblePart);
visiblePart->SetFocus();
}
//window.getShell().setRedraw(true);
//parentWidget.setRedraw(true);
}
}
void PerspectiveHelper::DetachPart(LayoutPart::Pointer part, int x, int y)
{
// Detaching is disabled on some platforms ..
if (!detachable)
{
return;
}
// Calculate detached window size.
Point size = part->GetSize();
if (size.x == 0 || size.y == 0)
{
ILayoutContainer::Pointer container = part->GetContainer();
if (container.Cast () != 0)
{
size = container.Cast()->GetSize();
}
}
int width = std::max(size.x, MIN_DETACH_WIDTH);
int height = std::max(size.y, MIN_DETACH_HEIGHT);
// Create detached window.
DetachedWindow::Pointer window(new DetachedWindow(page));
detachedWindowList.push_back(window);
// Open window.
window->Create();
window->GetShell()->SetBounds(x, y, width, height);
window->Open();
// remove the part from its current container
this->DerefPart(part);
// add part to detached window.
window->Add(part);
part->SetFocus();
}
void PerspectiveHelper::DetachPart(IViewReference::Pointer ref)
{
PartPane::Pointer pane = ref.Cast()->GetPane();
if (this->CanDetach() && pane != 0)
{
// if (getMaximizedStack() != 0)
// getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED);
Rectangle bounds = pane->GetParentBounds();
this->DetachPart(pane, bounds.x, bounds.y);
}
}
void PerspectiveHelper::AddDetachedPart(LayoutPart::Pointer part)
{
// Calculate detached window size.
Rectangle bounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(parentWidget)->GetBounds();
bounds.x = bounds.x + (bounds.width - 300) / 2;
bounds.y = bounds.y + (bounds.height - 300) / 2;
this->AddDetachedPart(part, bounds);
}
void PerspectiveHelper::AddDetachedPart(LayoutPart::Pointer part,
const Rectangle& bounds)
{
// Detaching is disabled on some platforms ..
if (!detachable)
{
this->AddPart(part);
return;
}
// Create detached window.
DetachedWindow::Pointer window(new DetachedWindow(page));
detachedWindowList.push_back(window);
window->Create();
// add part to detached window.
part->CreateControl(window->GetShell()->GetControl());
window->Add(part);
// Open window.
window->GetShell()->SetBounds(bounds.x, bounds.y, bounds.width, bounds.height);
window->Open();
part->SetFocus();
}
void PerspectiveHelper::DisableAllDrag()
{
DragUtil::RemoveDragTarget(0, dragTarget.data());
}
void PerspectiveHelper::EnableAllDrag()
{
DragUtil::AddDragTarget(0, dragTarget.data());
}
LayoutPart::Pointer PerspectiveHelper::FindPart(const QString& id)
{
return this->FindPart(id, "");
}
LayoutPart::Pointer PerspectiveHelper::FindPart(const QString& primaryId,
const QString& secondaryId)
{
//BERRY_INFO << "Looking for part: " << primaryId << ":" << secondaryId << std::endl;
// check main window.
QList matchingParts;
LayoutPart::Pointer part = (secondaryId != "") ? this->FindPart(primaryId, secondaryId,
mainLayout->GetChildren(), matchingParts) : this->FindPart(primaryId,
mainLayout->GetChildren(), matchingParts);
if (part != 0)
{
return part;
}
// check each detached windows.
for (DetachedWindowsType::iterator iter = detachedWindowList.begin();
iter != detachedWindowList.end(); ++iter)
{
DetachedWindow::Pointer window = *iter;
part = (secondaryId != "") ? this->FindPart(primaryId, secondaryId,
window->GetChildren(), matchingParts) : this->FindPart(primaryId,
window->GetChildren(), matchingParts);
if (part != 0)
{
return part;
}
}
for (DetachedPlaceHoldersType::iterator iter = detachedPlaceHolderList.begin();
iter != detachedPlaceHolderList.end(); ++iter)
{
DetachedPlaceHolder::Pointer holder = *iter;
part = (secondaryId != "") ? this->FindPart(primaryId, secondaryId,
holder->GetChildren(), matchingParts) : this->FindPart(primaryId,
holder->GetChildren(), matchingParts);
if (part != 0)
{
return part;
}
}
//BERRY_INFO << "Looking through the matched parts (count: " << matchingParts.size() << ")\n";
// sort the matching parts
if (matchingParts.size()> 0)
{
std::partial_sort(matchingParts.begin(), (matchingParts.begin()), matchingParts.end(), CompareMatchingParts());
const MatchingPart& mostSignificantPart = matchingParts.front();
return mostSignificantPart.part;
}
// Not found.
return LayoutPart::Pointer(0);
}
LayoutPart::Pointer PerspectiveHelper::FindPart(const QString& id,
const QList& parts,
QList& matchingParts)
{
for (QList::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
// check for part equality, parts with secondary ids fail
if (part->GetID() == id)
{
if (part.Cast () != 0)
{
PartPane::Pointer pane = part.Cast();
IViewReference::Pointer ref = pane->GetPartReference().Cast();
if (ref->GetSecondaryId() != "")
{
continue;
}
}
return part;
}
// check pattern matching placeholders
else if (part->IsPlaceHolder()
&& part.Cast()->HasWildCard())
{
QRegExp re(id, Qt::CaseInsensitive);
if (re.exactMatch(part->GetID()))
{
matchingParts.push_back(MatchingPart(part->GetID(), "", part));
}
// StringMatcher sm = new StringMatcher(part.getID(), true, false);
// if (sm.match(id))
// {
// matchingParts .add(new MatchingPart(part.getID(), 0, part));
// }
}
else if (ILayoutContainer::Pointer layoutContainer = part.Cast())
{
part = FindPart(id, layoutContainer->GetChildren(),
matchingParts);
if (part)
{
return part;
}
}
}
//BERRY_INFO << "Returning 0\n";
return LayoutPart::Pointer(0);
}
LayoutPart::Pointer PerspectiveHelper::FindPart(const QString& primaryId,
const QString& secondaryId,
const QList& parts,
QList& matchingParts)
{
for (QList::const_iterator iter = parts.begin();
iter != parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
// check containers first
if (ILayoutContainer::Pointer layoutContainer = part.Cast())
{
LayoutPart::Pointer testPart = FindPart(primaryId, secondaryId,
layoutContainer->GetChildren(), matchingParts);
if (testPart)
{
return testPart;
}
}
// check for view part equality
if (part.Cast () != 0)
{
PartPane::Pointer pane = part.Cast();
IViewReference::Pointer ref = pane->GetPartReference().Cast();
if (ref->GetId() == primaryId && ref->GetSecondaryId() == secondaryId)
{
return part;
}
}
// check placeholders
else if (part.Cast () != 0)
{
QString id = part->GetID();
// optimization: don't bother parsing id if it has no separator -- it can't match
QString phSecondaryId = ViewFactory::ExtractSecondaryId(id);
if (phSecondaryId == "")
{
// but still need to check for wildcard case
if (id == PartPlaceholder::WILD_CARD)
{
matchingParts.push_back(MatchingPart(id, "", part));
}
continue;
}
QString phPrimaryId = ViewFactory::ExtractPrimaryId(id);
// perfect matching pair
if (phPrimaryId == primaryId && phSecondaryId == secondaryId)
{
return part;
}
// check for partial matching pair
QRegExp pre(phPrimaryId, Qt::CaseInsensitive);
if (pre.exactMatch(primaryId))
{
QRegExp sre(phSecondaryId, Qt::CaseInsensitive);
if (sre.exactMatch(secondaryId))
{
matchingParts.push_back(MatchingPart(phPrimaryId, phSecondaryId, part));
}
}
}
}
return LayoutPart::Pointer(0);
}
bool PerspectiveHelper::HasPlaceholder(const QString& id)
{
return this->HasPlaceholder(id, 0);
}
bool PerspectiveHelper::HasPlaceholder(const QString& primaryId,
const QString& secondaryId)
{
LayoutPart::Pointer testPart;
if (secondaryId == "")
{
testPart = this->FindPart(primaryId);
}
else
{
testPart = this->FindPart(primaryId, secondaryId);
}
return (testPart != 0 && testPart.Cast () != 0);
}
PartSashContainer::Pointer PerspectiveHelper::GetLayout() const
{
return mainLayout;
}
bool PerspectiveHelper::IsActive()
{
return active;
}
float PerspectiveHelper::GetDockingRatio(LayoutPart::Pointer source,
LayoutPart::Pointer target)
{
if ((source.Cast () != 0 || source.Cast () != 0)
&& target.Cast () != 0)
{
return 0.25f;
}
return 0.5f;
}
void PerspectiveHelper::RemovePart(LayoutPart::Pointer part)
{
// Reparent the part back to the main window
void* parent = mainLayout->GetParent();
part->Reparent(parent);
// Replace part with a placeholder
ILayoutContainer::Pointer container = part->GetContainer();
if (container != 0)
{
QString placeHolderId = part->GetPlaceHolderId();
container->Replace(part, LayoutPart::Pointer(new PartPlaceholder(placeHolderId)));
// // If the parent is root we're done. Do not try to replace
// // it with placeholder.
// if (container == mainLayout)
// {
// return;
// }
// If the parent is empty replace it with a placeholder.
QList children = container->GetChildren();
bool allInvisible = true;
for (QList::iterator childIter = children.begin();
childIter != children.end(); ++childIter)
{
if (childIter->Cast () == 0)
{
allInvisible = false;
break;
}
}
if (allInvisible && (container.Cast () != 0))
{
// what type of window are we in?
LayoutPart::Pointer cPart = container.Cast();
//Window oldWindow = cPart.getWindow();
bool wasDocked = cPart->IsDocked();
Shell::Pointer oldShell = cPart->GetShell();
if (wasDocked)
{
// PR 1GDFVBY: ViewStack not disposed when page
// closed.
if (container.Cast () != 0)
{
container.Cast()->Dispose();
}
// replace the real container with a
// ContainerPlaceholder
ILayoutContainer::Pointer parentContainer = cPart->GetContainer();
ContainerPlaceholder::Pointer placeholder(
new ContainerPlaceholder(cPart->GetID()));
placeholder->SetRealContainer(container);
parentContainer->Replace(cPart, placeholder);
}
else
{
DetachedPlaceHolder::Pointer placeholder(
new DetachedPlaceHolder("", oldShell->GetBounds())); //$NON-NLS-1$
for (QList::iterator childIter2 = children.begin();
childIter2 != children.end(); ++childIter2)
{
(*childIter2)->GetContainer()->Remove(*childIter2);
(*childIter2)->SetContainer(placeholder);
placeholder->Add(*childIter2);
}
detachedPlaceHolderList.push_back(placeholder);
DetachedWindow::Pointer w = oldShell->GetData().Cast();
oldShell->Close();
detachedWindowList.removeAll(w);
}
}
}
}
void PerspectiveHelper::ReplacePlaceholderWithPart(LayoutPart::Pointer part)
{
// Look for a PartPlaceholder that will tell us how to position this
// object
QList placeholders = this->CollectPlaceholders();
for (int i = 0; i < placeholders.size(); i++)
{
if (placeholders[i]->GetID() == part->GetID())
{
// found a matching placeholder which we can replace with the
// new View
ILayoutContainer::Pointer container = placeholders[i]->GetContainer();
if (container != 0)
{
if (ContainerPlaceholder::Pointer containerPlaceholder = container.Cast ())
{
// One of the children is now visible so replace the
// ContainerPlaceholder with the real container
ILayoutContainer::Pointer parentContainer =
containerPlaceholder->GetContainer();
container = containerPlaceholder->GetRealContainer().Cast();
if (LayoutPart::Pointer layoutPart = container.Cast ())
{
parentContainer->Replace(containerPlaceholder, layoutPart);
}
containerPlaceholder->SetRealContainer(ILayoutContainer::Pointer(0));
}
container->Replace(placeholders[i], part);
return;
}
}
}
}
bool PerspectiveHelper::RestoreState(IMemento::Pointer memento)
{
// Restore main window.
IMemento::Pointer childMem = memento->GetChild(WorkbenchConstants::TAG_MAIN_WINDOW);
//IStatus r = mainLayout->RestoreState(childMem);
bool r = mainLayout->RestoreState(childMem);
// Restore each floating window.
if (detachable)
{
QList detachedWindows(memento->GetChildren(
WorkbenchConstants::TAG_DETACHED_WINDOW));
for (QList::iterator iter = detachedWindows.begin();
iter != detachedWindows.end(); ++iter)
{
DetachedWindow::Pointer win(new DetachedWindow(page));
detachedWindowList.push_back(win);
win->RestoreState(*iter);
}
QList childrenMem(memento->GetChildren(
WorkbenchConstants::TAG_HIDDEN_WINDOW));
for (QList::iterator iter = childrenMem.begin();
iter != childrenMem.end(); ++iter)
{
DetachedPlaceHolder::Pointer holder(
new DetachedPlaceHolder("", Rectangle(0, 0, 0, 0)));
holder->RestoreState(*iter);
detachedPlaceHolderList.push_back(holder);
}
}
// Get the cached id of the currently maximized stack
//maximizedStackId = childMem.getString(IWorkbenchConstants.TAG_MAXIMIZED);
return r;
}
bool PerspectiveHelper::SaveState(IMemento::Pointer memento)
{
// Persist main window.
IMemento::Pointer childMem = memento->CreateChild(WorkbenchConstants::TAG_MAIN_WINDOW);
//IStatus r = mainLayout->SaveState(childMem);
bool r = mainLayout->SaveState(childMem);
if (detachable)
{
// Persist each detached window.
for (DetachedWindowsType::iterator iter = detachedWindowList.begin();
iter != detachedWindowList.end(); ++iter)
{
childMem = memento->CreateChild(WorkbenchConstants::TAG_DETACHED_WINDOW);
(*iter)->SaveState(childMem);
}
for (DetachedPlaceHoldersType::iterator iter = detachedPlaceHolderList.begin();
iter != detachedPlaceHolderList.end(); ++iter)
{
childMem = memento->CreateChild(WorkbenchConstants::TAG_HIDDEN_WINDOW);
(*iter)->SaveState(childMem);
}
}
// Write out the id of the maximized (View) stack (if any)
// NOTE: we only write this out if it's a ViewStack since the
// Editor Area is handled by the perspective
// if (maximizedStack.Cast () != 0)
// {
// childMem.putString(IWorkbenchConstants.TAG_MAXIMIZED,
// maximizedStack.getID());
// }
// else if (maximizedStackId != 0)
// {
// // Maintain the cache if the perspective has never been activated
// childMem.putString(IWorkbenchConstants.TAG_MAXIMIZED, maximizedStackId);
// }
return r;
}
void PerspectiveHelper::UpdateBoundsMap()
{
boundsMap.clear();
// Walk the layout gathering the current bounds of each stack
// and the editor area
QList kids = mainLayout->GetChildren();
for (QList::iterator iter = kids.begin();
iter != kids.end(); ++iter)
{
if (iter->Cast () != 0)
{
PartStack::Pointer vs = iter->Cast();
boundsMap.insert(vs->GetID(), vs->GetBounds());
}
else if (iter->Cast () != 0)
{
EditorSashContainer::Pointer esc = iter->Cast();
boundsMap.insert(esc->GetID(), esc->GetBounds());
}
}
}
void PerspectiveHelper::ResetBoundsMap()
{
boundsMap.clear();
}
Rectangle PerspectiveHelper::GetCachedBoundsFor(const QString& id)
{
return boundsMap[id];
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveRegistry.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveRegistry.cpp
index 970c8acd90..a8b181b43c 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveRegistry.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPerspectiveRegistry.cpp
@@ -1,591 +1,590 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryPerspectiveRegistry.h"
#include "berryWorkbench.h"
#include "berryWorkbenchPlugin.h"
#include "berryPerspectiveRegistryReader.h"
-
namespace berry
{
const QString PerspectiveRegistry::EXT = "_persp.xml";
const QString PerspectiveRegistry::ID_DEF_PERSP = "PerspectiveRegistry.DEFAULT_PERSP";
const QString PerspectiveRegistry::PERSP = "_persp";
const char PerspectiveRegistry::SPACE_DELIMITER = ' ';
PerspectiveRegistry::PerspectiveRegistry()
{
//IExtensionTracker tracker = PlatformUI.getWorkbench() .getExtensionTracker();
//tracker.registerHandler(this, null);
//this->InitializePreferenceChangeListener();
//WorkbenchPlugin::GetDefault()->GetPreferenceStore()->AddPropertyChangeListener(
// preferenceListener);
}
void PerspectiveRegistry::AddPerspective(PerspectiveDescriptor::Pointer desc)
{
if (desc == 0)
{
return;
}
this->Add(desc);
}
IPerspectiveDescriptor::Pointer PerspectiveRegistry::CreatePerspective(const QString& label,
IPerspectiveDescriptor::Pointer originalDescriptor)
{
// Sanity check to avoid invalid or duplicate labels.
if (!this->ValidateLabel(label))
{
return IPerspectiveDescriptor::Pointer(0);
}
if (this->FindPerspectiveWithLabel(label) != 0)
{
return IPerspectiveDescriptor::Pointer(0);
}
// Calculate ID.
QString id(label);
id = id.replace(' ', '_').trimmed();
// Create descriptor.
PerspectiveDescriptor::Pointer desc(
new PerspectiveDescriptor(id, label, originalDescriptor.Cast()));
this->Add(desc);
- return desc.GetPointer();
+ return IPerspectiveDescriptor::Pointer(static_cast(desc.GetPointer()));
}
void PerspectiveRegistry::RevertPerspectives(
const QList& perspToRevert)
{
// indicate that the user is removing these perspectives
for (QList::const_iterator iter = perspToRevert.begin();
iter != perspToRevert.end(); ++iter)
{
PerspectiveDescriptor::Pointer desc = *iter;
perspToRemove.push_back(desc->GetId());
desc->RevertToPredefined();
}
}
void PerspectiveRegistry::DeletePerspectives(
const QList& perspToDelete)
{
for (QList::const_iterator iter = perspToDelete.begin();
iter != perspToDelete.end(); ++iter)
{
this->DeletePerspective(*iter);
}
}
void PerspectiveRegistry::DeletePerspective(IPerspectiveDescriptor::Pointer in)
{
PerspectiveDescriptor::Pointer desc = in.Cast();
// Don't delete predefined perspectives
if (!desc->IsPredefined())
{
perspToRemove.push_back(desc->GetId());
perspectives.removeAll(desc);
desc->DeleteCustomDefinition();
this->VerifyDefaultPerspective();
}
}
IPerspectiveDescriptor::Pointer PerspectiveRegistry::FindPerspectiveWithId(const QString& id)
{
for (QList::iterator iter = perspectives.begin();
iter != perspectives.end(); ++iter)
{
PerspectiveDescriptor::Pointer desc = *iter;
if (desc->GetId() == id)
{
// if (WorkbenchActivityHelper.restrictUseOf(desc))
// {
// return null;
// }
return desc;
}
}
return IPerspectiveDescriptor::Pointer(0);
}
IPerspectiveDescriptor::Pointer PerspectiveRegistry::FindPerspectiveWithLabel(
const QString& label)
{
for (QList::iterator iter = perspectives.begin();
iter != perspectives.end(); ++iter)
{
PerspectiveDescriptor::Pointer desc = *iter;
if (desc->GetLabel() == label)
{
// if (WorkbenchActivityHelper.restrictUseOf(desc))
// {
// return 0;
// }
return desc;
}
}
return IPerspectiveDescriptor::Pointer(0);
}
QString PerspectiveRegistry::GetDefaultPerspective()
{
return defaultPerspID;
}
QList PerspectiveRegistry::GetPerspectives()
{
// Collection descs = WorkbenchActivityHelper.restrictCollection(perspectives,
// new ArrayList());
// return (IPerspectiveDescriptor[]) descs.toArray(
// new IPerspectiveDescriptor[descs.size()]);
QList result;
for (QList::iterator iter = perspectives.begin();
iter != perspectives.end(); ++iter)
{
result.push_back(iter->Cast());
}
return result;
}
void PerspectiveRegistry::Load()
{
// Load the registries.
this->LoadPredefined();
this->LoadCustom();
// Get default perspective.
// Get it from the R1.0 dialog settings first. Fixes bug 17039
// IDialogSettings dialogSettings =
// WorkbenchPlugin.getDefault() .getDialogSettings();
// QString str = dialogSettings.get(ID_DEF_PERSP);
// if (str != null && str.length() > 0)
// {
// this->SetDefaultPerspective(str);
// dialogSettings.put(ID_DEF_PERSP, ""); //$NON-NLS-1$
// }
this->VerifyDefaultPerspective();
}
//void PerspectiveRegistry::SaveCustomPersp(PerspectiveDescriptor::Pointer desc,
// XMLMemento::Pointer memento)
//{
//
// IPreferenceStore store = WorkbenchPlugin.getDefault() .getPreferenceStore();
//
// // Save it to the preference store.
// Writer writer = new StringWriter();
//
// memento.save(writer);
// writer.close();
// store.setValue(desc.getId() + PERSP, writer.toString());
//
//}
IMemento::Pointer PerspectiveRegistry::GetCustomPersp(const QString& /*id*/)
{
//TODO CustomPersp
// Reader reader = null;
//
// IPreferenceStore store = WorkbenchPlugin.getDefault() .getPreferenceStore();
// QString xmlString = store.getString(id + PERSP);
// if (xmlString != null && xmlString.length() != 0)
// { // defined in store
// reader = new StringReader(xmlString);
// }
// XMLMemento memento = XMLMemento.createReadRoot(reader);
// reader.close();
// return memento;
return IMemento::Pointer(0);
}
void PerspectiveRegistry::SetDefaultPerspective(const QString& id)
{
IPerspectiveDescriptor::Pointer desc = this->FindPerspectiveWithId(id);
if (desc != 0)
{
defaultPerspID = id;
//TODO Preferences
// PrefUtil.getAPIPreferenceStore().setValue(
// IWorkbenchPreferenceConstants.DEFAULT_PERSPECTIVE_ID, id);
}
}
bool PerspectiveRegistry::ValidateLabel(const QString& label)
{
return !label.trimmed().isEmpty();
}
IPerspectiveDescriptor::Pointer PerspectiveRegistry::ClonePerspective(const QString& id,
const QString& label,
IPerspectiveDescriptor::Pointer originalDescriptor)
{
// Check for invalid labels
if (label == "" || label.trimmed().isEmpty())
{
throw Poco::InvalidArgumentException();
}
// Check for duplicates
IPerspectiveDescriptor::Pointer desc = this->FindPerspectiveWithId(id);
if (desc != 0)
{
throw Poco::InvalidArgumentException();
}
// Create descriptor.
desc
= new PerspectiveDescriptor(id, label, originalDescriptor.Cast